Home || Visual Search || Applications || Architecture || Important Messages || OGL || Src

int UDPSocket::recvFrom ( void *  buffer,
int  bufferLen,
string &  sourceAddress,
unsigned short &  sourcePort 
) throw (SocketException)

Read read up to bufferLen bytes data from this socket.

The given buffer is where the data will be placed

Parameters:
buffer buffer to receive data
bufferLen maximum number of bytes to receive
sourceAddress address of datagram source
sourcePort port of data source
Returns:
number of bytes received and -1 for error
Exceptions:
SocketException thrown if unable to receive datagram

Definition at line 340 of file PracticalSocket.cpp.

References Socket::sockDesc.

00341                                                        {
00342   sockaddr_in clntAddr;
00343   socklen_t addrLen = sizeof(clntAddr);
00344   int rtn;
00345   if ((rtn = recvfrom(sockDesc, (raw_type *) buffer, bufferLen, 0, 
00346                       (sockaddr *) &clntAddr, (socklen_t *) &addrLen)) < 0) {
00347     throw SocketException("Receive failed (recvfrom())", true);
00348   }
00349   sourceAddress = inet_ntoa(clntAddr.sin_addr);
00350   sourcePort = ntohs(clntAddr.sin_port);
00351 
00352   return rtn;
00353 }


Generated on Thu Jan 13 09:13:09 2011 for ImpalaSrc by  doxygen 1.5.1