sceNetInetSetsockopt

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
liquid8d
Posts: 66
Joined: Thu Jun 30, 2005 6:29 am

sceNetInetSetsockopt

Post by liquid8d »

Hey,

I was hoping maybe someone has worked some more with sockets and got some of the socket options figured out. From what I see in the latest stuff from PSPPet, it looks like he hasn't gotten into the sockopts yet.

Basically, I just need to be able to timeout sceInetConnect. Is this what I need? I could setup a connect thread and a timeout thread, but that seems a bit much.

LiQuiD8d
reakt
Posts: 22
Joined: Fri May 06, 2005 8:35 pm
Location: Basingstoke, UK

Post by reakt »

Take a look in PspPet's wifi sample 002,
nlh.c
there's a function called:
nlhSimpleConnectWithTimeout

Here he sets the socket options, to make a non-blocking socket

sceNetInetSetsockopt(s, SOL_SOCKET, 0x1009, (const char*)&val, sizeof(u32));

If you look at the rest of the function you'll see that the socket is polled for a finite period of time (the timeout).

So this solves your issue.

Personally I would like to request event notification for a socket. Specifically, the event FD_CONNECT is interesting. This would enable an asynchronous connection facility, so no socket polling would be necessary.
Does anyone know how to do this with the PSP socket library? With winsock, WSAAsyncSelect() is used for this.
PspPet
Posts: 210
Joined: Wed Mar 30, 2005 2:13 am
Contact:

Post by PspPet »

> was hoping maybe someone has worked some more with sockets and got some of the socket options figured out.
As mentioned, see the Wifi .02 sample.
In "my_socket.h".

Code: Select all

//  NOTE: many do not work as you would expect (ie. setting RCVTIMEO)
//    experiment before relying on anything.
The 'nlhSimpleConnectWithTimeout' is a sleazy workaround since the RCVTIMEO socket option isn't supported.
The Sony socket implementation is non-standard and they appear to have cut corners. Alhough they patterened the interface on Berkeley sockets, don't rely on any specific behavior unless you've tested it yourself.
[ie "beggers can't be choosers" ;=]
liquid8d
Posts: 66
Joined: Thu Jun 30, 2005 6:29 am

Post by liquid8d »

That works for me, I'll give it a shot tonight. I must have missed that in the .02 version, thanks guys. (i kind of copied and pasted the new stuff into what I had from original wifi src)

That's all I really need at the moment, but looking over some ftp client source, I have seen some of the "fallback" connection things that are used, which I may need to look into later. (again, I am learning the socket stuff as I go)

LiQuiD8d
Post Reply