mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-22 09:38:01 +02:00
Added out sockAddrs for Connect/AcceptFrom
This commit is contained in:
parent
13c66a7d31
commit
035335bf7b
1 changed files with 8 additions and 4 deletions
|
@ -397,8 +397,9 @@ namespace System.Net
|
||||||
return .Ok;
|
return .Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Result<void> Connect(StringView addr, int32 port)
|
public Result<void> Connect(StringView addr, int32 port, out SockAddr_in sockAddr)
|
||||||
{
|
{
|
||||||
|
sockAddr = default;
|
||||||
mHandle = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
mHandle = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||||
if (mHandle == INVALID_SOCKET)
|
if (mHandle == INVALID_SOCKET)
|
||||||
return .Err;
|
return .Err;
|
||||||
|
@ -407,7 +408,6 @@ namespace System.Net
|
||||||
if (hostEnt == null)
|
if (hostEnt == null)
|
||||||
return .Err;
|
return .Err;
|
||||||
|
|
||||||
SockAddr_in sockAddr;
|
|
||||||
sockAddr.sin_family = AF_INET;
|
sockAddr.sin_family = AF_INET;
|
||||||
Internal.MemCpy(&sockAddr.sin_addr, hostEnt.h_addr_list[0], sizeof(IPv4Address));
|
Internal.MemCpy(&sockAddr.sin_addr, hostEnt.h_addr_list[0], sizeof(IPv4Address));
|
||||||
sockAddr.sin_port = (uint16)htons((int16)port);
|
sockAddr.sin_port = (uint16)htons((int16)port);
|
||||||
|
@ -428,9 +428,11 @@ namespace System.Net
|
||||||
return .Ok;
|
return .Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Result<void> AcceptFrom(Socket listenSocket)
|
public Result<void> Connect(StringView addr, int32 port) => Connect(addr, port, ?);
|
||||||
|
|
||||||
|
public Result<void> AcceptFrom(Socket listenSocket, out SockAddr_in clientAddr)
|
||||||
{
|
{
|
||||||
SockAddr_in clientAddr;
|
clientAddr = default;
|
||||||
int32 clientAddrLen = sizeof(SockAddr_in);
|
int32 clientAddrLen = sizeof(SockAddr_in);
|
||||||
mHandle = accept(listenSocket.mHandle, &clientAddr, &clientAddrLen);
|
mHandle = accept(listenSocket.mHandle, &clientAddr, &clientAddrLen);
|
||||||
if (mHandle == INVALID_SOCKET)
|
if (mHandle == INVALID_SOCKET)
|
||||||
|
@ -445,6 +447,8 @@ namespace System.Net
|
||||||
return .Ok;
|
return .Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Result<void> AcceptFrom(Socket listenSocket) => AcceptFrom(listenSocket, ?);
|
||||||
|
|
||||||
public static int32 Select(FDSet* readFDS, FDSet* writeFDS, FDSet* exceptFDS, int waitTimeMS)
|
public static int32 Select(FDSet* readFDS, FDSet* writeFDS, FDSet* exceptFDS, int waitTimeMS)
|
||||||
{
|
{
|
||||||
TimeVal timeVal;
|
TimeVal timeVal;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue