|
Here you go. I think it's all copied from your sample program(s). The RTVNETADS
procedure I heisted from, I think, IT Jungle or somewhere like that.
. ** ----------------------------------------------------------------
**
** socket--Create Socket
**
** int socket(int address_family,
** int type,
** int protocol)
**
D p_sockaddr S *
D SockAddr DS based(p_sockaddr)
D SA_Family 5U 0
D SA_Data 14A
** Socket Address (Internet)
**
** struct sockaddr_in {
** short sin_family;
** u_short sin_port;
** struct in_addr sin_addr;
** char sin_zero[8];
** };
**
D sockaddr_in DS based(p_sockaddr)
D sin_Family 5I 0
D sin_Port 5U 0
D sin_addr 10U 0
D sin_zero 8A
**
** The socket() function is used to create an end point for
** communications. The end point is represented by the
** socket descriptor returned by the socket() function.
**
** ----------------------------------------------------------------
D socket PR 10I 0 ExtProc('socket')
D AddrFamily 10I 0 Value
D SocketType 10I 0 Value
D Protocol 10I 0 Value
C*************************************************
C* Create a socket
C*************************************************
c eval sock = socket(AF_INET: SOCK_STREAM:
c IPPROTO_IP)
c if sock < 0
c callp die('socket(): ' + %str(strerror(errno)))
c return
c endif
C*************************************************
C* Create a socket address structure that
C* describes the host & port we wanted to
C* connect to
C*************************************************
c eval addrlen = %size(sockaddr)
c alloc addrlen p_connto
c eval p_sockaddr = p_connto
c eval sin_family = AF_INET
c eval sin_addr = addr
CL0N01Factor1+++++++Opcode&ExtExtended-factor2+++++++++++++++++++++++++++++
c eval sin_zero = *ALLx'00'
C Eval sin_Port = 3940
* Retrieve IP Address of PC
C Eval I_Net_Adr = RtvNetAds(Device)
C Eval I_Net_Adr = %trim(I_Net_Adr)
C Eval sin_addr = addrCvtr(I_Net_Adr)
C*************************************************
* Connect to command server on PC
C*************************************************
C Eval Retn = connect(sock: p_connto: addrlen)
C if Retn < 0
c callp close(sock)
C Eval *Inlr = *On
C Return
C Endif
*
*---------------------------------------------------------
* RtvNetAds - Subprocedure To Retrieve PC's IP Address
*---------------------------------------------------------
P RtvNetAds B Export
D RtvNetAds PI 20A
D Inp_Device 10A Const
D Apierr DS
D Bytprv 1 4B 0 Inz(216)
D Bytavl 5 8B 0 Inz
D Errid 9 15A Inz
D Rsvd 16 16A Inz
D Errdta 17 216A Inz
D Net_Address S 20A INZ
D Format S 8A Inz('DEVD0600')
D Rcvar S 5000A Inz
D Varlen S 4B 0 Inz(5000)
C Eval Device = Inp_Device
C Call 'QDCRDEVD'
C Parm Rcvar
C Parm Varlen
C Parm Format
C Parm Device
C Parm Apierr
C If BytAvl = 0
C Eval Net_Address = %Subst(Rcvar:877:16)
C Endif
C Return Net_Address
P RtvNetAds E
*-------------------------------------------------------------
Scott Klement <rpg400-l@xxxxxxxxxxxxxxxx> wrote: > Straight off of Scott's
website. I can't remember if this is from the
> first sample sockets program or one of the later ones there, but I think
> it's the same prototype regardless:
The prototype is okay. How about the call to socket()?
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.