IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

ezasoket: how can I specify IP & PORT in BIND


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 8696
Location: Dubuque, Iowa, USA

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

The manual documentation at 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
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: 1281
Location: Belgium

PostPosted: Mon Dec 30, 2013 6:53 pm
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 :
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
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Mon Dec 30, 2013 7:54 pm
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
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Mon Dec 30, 2013 8:24 pm
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: 2501
Location: Atlanta, Georgia, USA

PostPosted: Mon Dec 30, 2013 8:25 pm
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
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
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
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: 2501
Location: Atlanta, Georgia, USA

PostPosted: Mon Jan 06, 2014 7:44 pm
Reply with quote

Ed,

I found it here -

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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Jan 06, 2014 7:51 pm
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
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: 2455
Location: Hampshire, UK

PostPosted: Tue Jan 07, 2014 9:48 pm
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: 1788
Location: Bloomington, IL

PostPosted: Tue Jan 07, 2014 10:24 pm
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: 2455
Location: Hampshire, UK

PostPosted: Wed Jan 08, 2014 4:06 am
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts JCL for pl1 db2 precompile, compile a... JCL & VSAM 4
No new posts Bind process DB2 4
No new posts Getting an error from EZASOKET while ... COBOL Programming 10
No new posts Defining SSL Port in TCPIP for DB2 Se... TSO/ISPF 1
No new posts How syntax check at Bind time is diff... DB2 5
Search our Forums:

Back to Top