Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

ezasoket: how can I specify IP & PORT in BIND

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
hkalhor

New User


Joined: 20 May 2007
Posts: 15
Location: Iran

PostPosted: Mon Dec 30, 2013 5:35 pm    Post subject: ezasoket: how can I specify IP & PORT in BIND
Reply with quote

Hi,
I nned to have a listener, and I tried to code that in cobol with 'EZASOKET',
now I need a sample or can any one help me how can I specify IP & PORT in BIND
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Mon Dec 30, 2013 6:21 pm    Post subject:
Reply with quote

The manual documentation at http://pic.dhe.ibm.com/infocenter/zos/v1r12/index.jsp?topic=%2Fcom.ibm.zos.r12.halc001%2Ff1a1g17040.htm seems pretty clear on how to specify both port and IP address.
Back to top
View user's profile Send private message
hkalhor

New User


Joined: 20 May 2007
Posts: 15
Location: Iran

PostPosted: Mon Dec 30, 2013 6:31 pm    Post subject:
Reply with quote

yes but the IP-address variable is pic 9(4) binary and the value is like
129.0.66.152 how dose it possible?
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1278
Location: Belgium

PostPosted: Mon Dec 30, 2013 6:53 pm    Post subject:
Reply with quote

hkalhor wrote:
yes but the IP-address variable is pic 9(4) binary and the value is like
129.0.66.152 how dose it possible?

You must have read wrong :
http://pic.dhe.ibm.com/infocenter/zos/v1r12/topic/com.ibm.zos.r12.halc001/cbind.htm#cbind
Back to top
View user's profile Send private message
hkalhor

New User


Joined: 20 May 2007
Posts: 15
Location: Iran

PostPosted: Mon Dec 30, 2013 7:31 pm    Post subject:
Reply with quote

as I found the value of the IP should be assigned in Hex but i don't know how?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Mon Dec 30, 2013 7:54 pm    Post subject:
Reply with quote

You must not be reading the same manual. The one I referenced gave PIC 9(8) BINARY for the IP address -- much different from PIC S9(04) COMP.

129 is X'81'
0 is X'00'
66 is X'42'
152 is X'98'
so 129.0.66.152 would be X'81004298' which can be the VALUE clause in COBOL.
Back to top
View user's profile Send private message
hkalhor

New User


Joined: 20 May 2007
Posts: 15
Location: Iran

PostPosted: Mon Dec 30, 2013 8:05 pm    Post subject:
Reply with quote

you mean IPaddress PIC S9(04) COMP value X'81004298. ?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Mon Dec 30, 2013 8:24 pm    Post subject:
Reply with quote

No, because PIC S9(04) COMP will not hold the value. You need to use PIC 9(8) COMP-5 instead -- note that there is NO sign in the PICTURE, the length is 8 not 4, and COMP-5 tells COBOL to NOT restrict the value to 8 decimal digits (the TRUNC compiler option value has no impact on COMP-5).
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Mon Dec 30, 2013 8:25 pm    Post subject: Reply to: ezasoket
Reply with quote

The binary-halfword is unsigned 9(04) COMP and therefore, has a maximum value of 65535 (X'FFFF'). To ensure that you don't have any problems with binary high-order truncation, your program needs to be compiled using the TRUNC(BIN) option or (if supported) define your COMP field as COMP-5 (Native Binary), which avoids all high-order truncation. When defining as COMP-5, the TRUNC compiler option has no effect.

I just Googled "ezasoket" and got many hits. So, if you're still confused, some of these sites should get you going.

HTH....
Back to top
View user's profile Send private message
Ed Goodman

Active Member


Joined: 08 Jun 2011
Posts: 556
Location: USA

PostPosted: Thu Jan 02, 2014 10:26 pm    Post subject:
Reply with quote

A little clunky, but this works fine:

Code:

01  WSH-ADR-SOCKET.                                   
    03 WSH-NBR-TCPIP-FAMILY PIC 9(04) COMP.           
    03 WSH-NBR-TCPIP-PORT   PIC 9(04) COMP.           
    03 WSH-ADR-TCPIP        PIC 9(08) COMP.           
    03 FILLER REDEFINES WSH-ADR-TCPIP.                 
       05 WSH-ADR-TCPIP-OCTET PIC X(01) OCCURS 4 TIMES.
    03 RESERVED             PIC X(08).                 


01  WSH-STRING-ALPHA.                                   
    03 WSH-STRING-A OCCURS 4 TIMES PIC X(03) JUST RIGHT.

01  WSH-ADR-TCPIP1.                                             
    03 WSH-CMP-TCPIP1-OCTET       PIC 9(04) COMP OCCURS 4 TIMES.
                                                               
01  FILLER REDEFINES WSH-ADR-TCPIP1.                           
    03 FILLER OCCURS 4 TIMES.                                   
       05 FILLER                  PIC X(01).                   
       05 WSH-ADR-TCPIP1-OCTET    PIC X(01).                   

MOVE SPACES TO WSH-STRING-ALPHA.                           
UNSTRING QWIQ046A-ADR-TCPIP DELIMITED BY '.' OR ' '       
    INTO WSH-STRING-A(1)                                   
         WSH-STRING-A(2)                                   
         WSH-STRING-A(3)                                   
         WSH-STRING-A(4).                                 
PERFORM VARYING WSI-SUB1 FROM 1 BY 1 UNTIL WSI-SUB1 > 4   
   INSPECT WSH-STRING-A(WSI-SUB1) REPLACING ALL ' ' BY '0'
   MOVE WSH-STRING-A(WSI-SUB1)                             
     TO WSH-CMP-TCPIP1-OCTET(WSI-SUB1)                     
   MOVE WSH-ADR-TCPIP1-OCTET(WSI-SUB1) TO                 
        WSH-ADR-TCPIP-OCTET(WSI-SUB1)                     
END-PERFORM.                                               

Back to top
View user's profile Send private message
hkalhor

New User


Joined: 20 May 2007
Posts: 15
Location: Iran

PostPosted: Mon Jan 06, 2014 2:02 pm    Post subject:
Reply with quote

Hi
thank you every one who tried to help, I found that "PTON' is the function for convert the formal IPADDRESS to binary.
Back to top
View user's profile Send private message
Ed Goodman

Active Member


Joined: 08 Jun 2011
Posts: 556
Location: USA

PostPosted: Mon Jan 06, 2014 7:32 pm    Post subject:
Reply with quote

whoa! That's a command I've never seen!

Is that a standard COBOL verb? Or maybe an intrinsic function?

Made unCOOL
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Mon Jan 06, 2014 7:44 pm    Post subject: Reply to: ezasoket: how can I specify IP & PORT in BIND
Reply with quote

Ed,

I found it here -

http://pic.dhe.ibm.com/infocenter/zos/v1r13/index.jsp?topic=%2Fcom.ibm.zos.r13.hala001%2Ff1a1d49079.htm
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Mon Jan 06, 2014 7:51 pm    Post subject: Reply to: ezasoket: how can I specify IP & PORT in BIND
Reply with quote

It would be really good if the BINARY definitions of the IP address were COMP-5 (perhaps some of the others as well).

As long as only passed as parameters, it won't cause a problem, but if any MOVEs are done with the IP address field, beware.
Back to top
View user's profile Send private message
Ed Goodman

Active Member


Joined: 08 Jun 2011
Posts: 556
Location: USA

PostPosted: Tue Jan 07, 2014 8:53 pm    Post subject:
Reply with quote

nice!

I wonder if that was there all along, like when my posted code was written, or if this is relatively new.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1715
Location: UK

PostPosted: Tue Jan 07, 2014 9:48 pm    Post subject: Reply to: ezasoket: how can I specify IP & PORT in BIND
Reply with quote

I did a search in the 5.1 language reference for PTON and it is not found. 5.1 is the latest available manual - unless I am pointed at the wrong place!
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Tue Jan 07, 2014 10:24 pm    Post subject: Re: Reply to: ezasoket: how can I specify IP & PORT in B
Reply with quote

Nic Clouston wrote:
I did a search in the 5.1 language reference for PTON and it is not found. 5.1 is the latest available manual - unless I am pointed at the wrong place!

PTON is a Communications Server function, not a COBOL verb or intrinsic function.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1715
Location: UK

PostPosted: Wed Jan 08, 2014 4:06 am    Post subject: Reply to: ezasoket: how can I specify IP & PORT in BIND
Reply with quote

Thanks for the "heads up", Akatsukami. Anyone referring to this topic now knows where to go to find the info.
Back to top
View user's profile Send private message
Ed Goodman

Active Member


Joined: 08 Jun 2011
Posts: 556
Location: USA

PostPosted: Wed Jan 08, 2014 8:52 pm    Post subject:
Reply with quote

I may be showing my nerdy side here, but learning about this function gives me a great feeling.

The team that put that ezasoket program together though about how to help, and added those functions. That's a really cool thing to know.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Cobol EZASOKET call to SETSOCKOPT fails Andi1982 COBOL Programming 6 Thu Oct 06, 2016 7:12 pm
No new posts What's plan, package, bind ? jackzhang75 DB2 2 Sun Feb 28, 2016 7:29 pm
No new posts What is Bind Error? Chetan Kumar Mainframe Interview Questions 1 Fri Oct 16, 2015 7:00 pm
No new posts Related to BIND parameters in DB2 sivareddy123 ABENDS & Debugging 2 Fri Jan 30, 2015 4:12 pm
No new posts DB2 BIND on a FOCUS Program Sumeendar DB2 2 Wed May 21, 2014 11:56 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us