![]() |
Connect() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
| Public Function |
Declared in: TCPSocket.h |
Declaration
virtual BOOL Connect(
int iSourcePort,
LPCSTR lpDestinationAddress,
int iDestinationPort);
DescriptionConnect to a remote system
Function Body
try
{
//Quit if not ok
if (!CheckSocketValid())
return FALSE;
if (isRaw())
return SendRaw(iSourcePort,lpDestinationAddress,iDestinationPort,NULL,0,TCPFlag_SYN);
else
{
//Set async notification
int iResult;
//Create the address
sockaddr_in soSrc;
//Set to 0
memset(&soSrc,0,sizeof(soSrc));
soSrc.sin_family=AF_INET;
soSrc.sin_addr.s_addr=inet_addr(lpDestinationAddress);
soSrc.sin_port=htons(iDestinationPort);
iResult=connect(GetHandle(),(sockaddr*)&soSrc,sizeof(soSrc));
//Check the result
if (iResult==SOCKET_ERROR)
{
//Check is it blocking error so we can ignore
#ifdef WIN32
if (WSAGetLastError()!=WSAEWOULDBLOCK)
#else
if (errno()!=EWOULDBLOCK)
#endif
SetLastError("Connect");
else
iResult=!SOCKET_ERROR;
}
else
SetLastError("Connect");
if (iResult!=SOCKET_ERROR)
//Save where we are connected
m_ConnectedTo=soSrc;
return iResult!=SOCKET_ERROR;
}
}
ERROR_HANDLER_RETURN("Connect",FALSE)
See Also
This web site was generated
using Surveyor V4.50.811.1. Click
here
for more information. |
Site content copyright © 2001 Barak Weichselbaum. See the About page for additional notices. This page last updated: 27 Jun 2001. |