mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
Web: void AttachSocket(Socket& socket, SOCKET s, bool blocking)
git-svn-id: svn://ultimatepp.org/upp/trunk@1599 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
d32a97b2d6
commit
e211a2903e
2 changed files with 18 additions and 2 deletions
|
|
@ -341,13 +341,18 @@ SOCKET Socket::Data::AcceptRaw(dword *ipaddr, int timeout_msec)
|
|||
return connection;
|
||||
}
|
||||
|
||||
void Socket::Data::Attach(SOCKET s, bool nodelay, bool blocking)
|
||||
void Socket::Data::AttachRaw(SOCKET s, bool blocking)
|
||||
{
|
||||
CloseRaw(0);
|
||||
socket = s;
|
||||
is_blocking = blocking;
|
||||
}
|
||||
|
||||
void Socket::Data::Attach(SOCKET s, bool nodelay, bool blocking)
|
||||
{
|
||||
AttachRaw(s, blocking);
|
||||
if(nodelay)
|
||||
NoDelay();
|
||||
is_blocking = blocking;
|
||||
if(!is_blocking)
|
||||
Block(false);
|
||||
}
|
||||
|
|
@ -837,6 +842,13 @@ bool ClientSocket(Socket& socket, const char *host, int port, bool nodelay, dwor
|
|||
return true;
|
||||
}
|
||||
|
||||
void AttachSocket(Socket& socket, SOCKET s, bool blocking)
|
||||
{
|
||||
One<Socket::Data> data = new Socket::Data;
|
||||
data->AttachRaw(s, blocking);
|
||||
socket.Attach(data);
|
||||
}
|
||||
|
||||
#ifdef PLATFORM_WIN32
|
||||
|
||||
void SocketEvent::Read(Socket& socket)
|
||||
|
|
|
|||
|
|
@ -56,6 +56,9 @@ public:
|
|||
SOCKET AcceptRaw(dword *ipaddr, int timeout_msec);
|
||||
void Attach(SOCKET socket, bool nodelay, bool is_blocking);
|
||||
void SetSockResError(String context);
|
||||
void AttachRaw(SOCKET s, bool blocking);
|
||||
|
||||
friend void AttachSocket(Socket& socket, SOCKET hsocket, bool blocking);
|
||||
};
|
||||
|
||||
Socket() {}
|
||||
|
|
@ -150,3 +153,4 @@ public:
|
|||
|
||||
bool ServerSocket(Socket& socket, int port, bool nodelay = true, int listen_count = 5, bool is_blocking = true, bool reuse = true);
|
||||
bool ClientSocket(Socket& socket, const char *host, int port, bool nodelay = true, dword *my_addr = NULL, int timeout = DEFAULT_CONNECT_TIMEOUT, bool is_blocking = true);
|
||||
void AttachSocket(Socket& socket, SOCKET s, bool blocking);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue