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.
