View previous topic :: View next topic
|
Author |
Message |
hkalhor
New User
Joined: 20 May 2007 Posts: 15 Location: Iran
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
Back to top |
|
|
hkalhor
New User
Joined: 20 May 2007 Posts: 15 Location: Iran
|
|
|
|
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 |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
Back to top |
|
|
hkalhor
New User
Joined: 20 May 2007 Posts: 15 Location: Iran
|
|
|
|
as I found the value of the IP should be assigned in Hex but i don't know how? |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
hkalhor
New User
Joined: 20 May 2007 Posts: 15 Location: Iran
|
|
|
|
you mean IPaddress PIC S9(04) COMP value X'81004298. ? |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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 |
|
|
Ed Goodman
Active Member
Joined: 08 Jun 2011 Posts: 556 Location: USA
|
|
|
|
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 |
|
|
hkalhor
New User
Joined: 20 May 2007 Posts: 15 Location: Iran
|
|
|
|
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 |
|
|
Ed Goodman
Active Member
Joined: 08 Jun 2011 Posts: 556 Location: USA
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Ed Goodman
Active Member
Joined: 08 Jun 2011 Posts: 556 Location: USA
|
|
|
|
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 |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
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 |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1787 Location: Bloomington, IL
|
|
|
|
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 |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
Thanks for the "heads up", Akatsukami. Anyone referring to this topic now knows where to go to find the info. |
|
Back to top |
|
|
Ed Goodman
Active Member
Joined: 08 Jun 2011 Posts: 556 Location: USA
|
|
|
|
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 |
|
|
|