Creating an Infrared Winsock Application
The basic procedure for using IrSock is similar to that for Winsock. IrSock uses only the TCP stream socket connection-oriented communication method. Server applications and client applications have different procedures.
Note You must include the Af_irda.h header file in your application to access IrSock features in the Winsock functions.
To create and use a socket with a server application
- Open a stream socket with socket. Use AF_IRDA for the address format parameter, SOCK_STREAM for the type and NULL for the protocol parameter.
- Bind the service name to the socket with bind. Pass a SOCKADDR_IRDA structure for the address parameter.
- Listen for an incoming client connection with listen.
- Accept an incoming client with accept.
- Use send and recv to communicate with the client.
- Close the socket with the closesocket function.
For an example of an Infrared Sockets server application, see Infrared Sockets Server.
To create and use a socket with a client application
- Open a stream socket with socket, as with the server application. Use AF_IRDA for the address format parameter, SOCK_STREAM for the type and NULL for the protocol parameter
- Search for the server, and retrieve its identifier with getsockopt.
- Connect to the server with the connect function using SOCKADDR_IRDA for the name parameter.
- Use send and recv to communicate with the server.
- Close the socket with closesocket.
For an example of an Infrared Sockets client application, see Infrared Sockets Client.