Group: Windows Sockets 2 (Winsock) - Library: ws2_32
How to build UDP responder
Winsock: how to retrieve a service information corresponding to a port
Winsock: how to retrieve a service information corresponding to a service name
Winsock: changing the byte ordering
Winsock: retrieving Web pages using sockets (HTTP, port 80)
Winsock: sending email messages (SMTP, port 25)
Winsock: retrieving directory listing from an FTP server using passive data connection (FTP, port 21)
Winsock: reading email messages (POP3, port 110)
Winsock: connecting to a news server (NNTP, port 119)
How to create non-blocking Winsock server
A client for testing non-blocking Winsock server
Winsock: resolving an address to a host name
u_short htons(
u_short hostshort
);
DECLARE INTEGER htons IN ws2_32;
INTEGER hostshort
hostshort [in] 16-bit number in host byte order.
The htons function returns the value in TCP/IP network byte order.
On newer Windows Systems htons sets bits after the 15th bit. Example:
? htons(465)
This returns on 32bit Systems the Value 53505, on 64bit Systems on newer Windows Version it returns 119041. When converting to binary it is clear, that the 16th bit is set:
01101000100000001 -> 53505
11101000100000001 -> 119041
Other values have other bits set. This causes some code to fail when the num2word function is used:
FUNCTION num2word(lnValue)
RETURN Chr(MOD(m.lnValue,256)) + CHR(INT(m.lnValue/256))
To resolve this, ignore everything after the 15th bit:
=num2word(BITAND(htons(587),65535))