Socket (Using UDP)

Socket (Using UDP)

When We creating sockets using UDP Protocol, we can Use the Following APIs

bind
connect
sendto
recvfrom

bind and connect are same as in TCP.

sendto:

Syntax:
int sendto ( int sid , const void *bufferPtr,size_t bufferLength , int flag ,
struct sockaddr *addrPtr , socklen_t addrLength )

Here,
Send a buffer, bufferPtr, of length bufferLength to address specified by addrPtr of size addrLength. Returns number of bytes sent or -1 on error.

recvfrom:

Syntax:
int recvfrom ( int sid , void *bufferPtr , int bufferLength ,
int flag , sockaddr *addrPtr ,int *addrLengthPtr )

Here,
Receive a buffer in bufferPtr of maximum length bufferLength from an unspecified sender.
Sender address returned in addrPtr, of size *addrLengthPtr.
Returns number of bytes receive or -1 on error.

Leave a Reply


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.