mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-01 12:07:31 +01:00
sceNetInet: Socket options as the PSP keeps them
The PSP's getsockopt and setsockopt work like 4.4BSD's, which pspautotests net/inet/options records in detail, and most of it didn't match: flags read back as their bit (SO_REUSEADDR as 4, SO_NBIO as 0x80), buffer sizes have their own defaults, getsockopt copies as much as fits and says how much, and unknown options and levels fail with ENOPROTOOPT and EINVAL. So the socket-level options are now kept in InetSocket, and only the ones that change what the host socket does are passed on to it. That also stops the timeouts reaching the host, where Winsock read the timeval as a millisecond count. Accepted sockets copy their options from the listener, like BSD's sonewconn(). IP_TTL is kept too, as Windows' default is 128 and the PSP's 64. Timeouts are set in microseconds, but kept in 10 ms clock ticks, and one under a tick is no timeout at all (net/inet/limits). Buffers can be up to 233016 bytes (net/inet/limits), 4.4BSD's limit with 256-byte mbufs, where we allowed 8 MB. SO_ERROR reads as an SCE error code rather than an errno (net/inet/tcp). The host's TCP send buffer is capped at 64 KB, closer to the PSP's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9bece86f08
commit
59e9d889e1
4 files changed
+239
-133
No files matched your search
@@ -42,6 +42,13 @@ InetSocket *SocketManager::CreateSocket(int *index, int *returned_errno, SocketS
|
||||
inetSock->type = type;
|
||||
inetSock->protocol = protocol;
|
||||
inetSock->nonblocking = false;
|
||||
// TCP and UDP defaults from pspautotests net/inet/options. Other types get UDP's.
|
||||
const bool stream = type == PSP_NET_INET_SOCK_STREAM;
|
||||
inetSock->sndBuf = stream ? 16384 : 9216;
|
||||
inetSock->rcvBuf = stream ? 16384 : 41600;
|
||||
inetSock->sndLowat = 2048;
|
||||
inetSock->rcvLowat = 1;
|
||||
inetSock->ipTtl = 64;
|
||||
*returned_errno = 0;
|
||||
return inetSock;
|
||||
}
|
||||
@@ -74,15 +81,12 @@ InetSocket *SocketManager::AdoptSocket(int *index, SOCKET hostSocket, const Inet
|
||||
|
||||
*index = i;
|
||||
InetSocket *inetSock = inetSockets_ + i;
|
||||
*inetSock = {};
|
||||
// Options and all, like BSD's sonewconn().
|
||||
*inetSock = *derive;
|
||||
inetSock->sock = hostSocket;
|
||||
inetSock->state = derive->state;
|
||||
inetSock->domain = derive->domain;
|
||||
inetSock->type = derive->type;
|
||||
inetSock->protocol = derive->protocol;
|
||||
inetSock->nonblocking = derive->nonblocking; // should we inherit blocking state?
|
||||
inetSock->recvTimeoutUs = derive->recvTimeoutUs;
|
||||
inetSock->sendTimeoutUs = derive->sendTimeoutUs;
|
||||
inetSock->addr.clear();
|
||||
inetSock->port = 0;
|
||||
inetSock->upnpPort = 0;
|
||||
return inetSock;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user