GETSOCKET

Top  Previous  Next

Action

Creates a socket for TCP/IP communication.

 

 

Syntax

Result = GETSOCKET(socket, mode, port, param)

 

 

Remarks

Result

A byte that is assigned with the socket number you requested. When the operation fails, it will return 255.

Mode

The socket mode. Use sock_stream(1), sock_dgrm(2), sock_ipl_raw(3), sock) or macl_raw(4). The modes are defined with constants.

 

For TCP/IP communication you need to specify sock_stream or the equivalent value 1.

 

For UDP communication you need to specify sock_dgrm or the equivalent value 2.

Port

This is the local port that will be used for the communication. You may specify any value you like but each socket must have it’s own local port number.

 

When you use 0, the value of LOCAL_PORT will be used.

 

LOCAL_PORT is assigned with CONFIG TCPIP.

 

After the assignment, LOCAL_PORT will be increased by 1. So the simplest way is to setup a local port with CONFIG TCPIP, and then use 0 for port.

Param

Optional parameter. Use 0 for default.

 

128 : send/receive broadcast message in UDP

64 : use register value with designated timeout value

32 : when not using no delayed ack

16: when not using silly window syndrome

 

Consult the W3100A documentation for more information.

 

After the socket has been initialized you can use SocketConnect to connect to a client, or SocketListen to act as a server.

 

 

See also

CONFIG TCPIP, SOCKETCONNECT, SOCKETSTAT , TCPWRITE, TCPWRITESTR, TCPREAD, CLOSESOCKET , SOCKETLISTEN

 

 

Partial Example

 

I = Getsocket(0 , Sock_stream , 5000 , 0)' get a new socket