bind failed
bind failed
Hi
I don't know whether this is problem is PSP or network related but it here it goes: I have a domotica system which is controlled by a dsp over a tcp/ip network. The dsp is always listening for a connection, a host (my pc mostly) connects to it, and after disconnecting the host the dsp starts listening again.
I ported the host to my PSP with the sdk, so now I can control lights etc in my room with the PSP, very nice. But after disconnecting the host on the PSP and putting it off, the dsp says "failed bind: address already in use" when it starts listening again..
It looks like the PSP connection hasn't disconnected although I call all these functions when closing:
sceNetApctlTerm();
sceNetResolverTerm();
sceNetInetTerm();
sceNetTerm();
anyone has an idea of what I can do more to let it disconnect properly?
Peace!
I don't know whether this is problem is PSP or network related but it here it goes: I have a domotica system which is controlled by a dsp over a tcp/ip network. The dsp is always listening for a connection, a host (my pc mostly) connects to it, and after disconnecting the host the dsp starts listening again.
I ported the host to my PSP with the sdk, so now I can control lights etc in my room with the PSP, very nice. But after disconnecting the host on the PSP and putting it off, the dsp says "failed bind: address already in use" when it starts listening again..
It looks like the PSP connection hasn't disconnected although I call all these functions when closing:
sceNetApctlTerm();
sceNetResolverTerm();
sceNetInetTerm();
sceNetTerm();
anyone has an idea of what I can do more to let it disconnect properly?
Peace!
If you are calling 'Close' and still getting the problem, it may be necessary to continue calling recv on the socket until it gracefully disconnects (either will turn a 0, or will return an error) before actually quitting the application.
or... you just just call sceKernelDelayThread(2000); ;) but honestly, receiving all of your data is the best way, so you can ensure you didnt miss any bytes in the stream.
or... you just just call sceKernelDelayThread(2000); ;) but honestly, receiving all of your data is the best way, so you can ensure you didnt miss any bytes in the stream.
ok I finally found it.. Appearentely I was calling nlhTerm() to quickly after sceInetClose( socket ) resulting in a lost [FIN,ACK] packet.
Putting a delay between the two didn't help, probabely because a deley just freezes the thread. So I made a seperate 'disconnect command', first call it from the gui on a keypress, close the socket, return control to the gui and then on the 'home' button call the nlhTerm etc.
Anyway, it works like a charm now, thanks for all the help!!
Putting a delay between the two didn't help, probabely because a deley just freezes the thread. So I made a seperate 'disconnect command', first call it from the gui on a keypress, close the socket, return control to the gui and then on the 'home' button call the nlhTerm etc.
Anyway, it works like a charm now, thanks for all the help!!
Thats very strange that you cant do a delay.
Oh, I think I know why.
err = sceNetApctlInit(0x1000, 0x42);
Change 0x42 to something much lower. 0x10 perhaps. And change:
err = sceNetInit(0x20000, 0x20, 0x1000, 0x20, 0x1000);
to have the two 0x20s be something more like 0x12.
That will ensure that your network thread is much higher priority than your main thread, so that network stuff will actually happen in the background. Then just do a sleep call for a few miliseconds and see what happens.
Oh, I think I know why.
err = sceNetApctlInit(0x1000, 0x42);
Change 0x42 to something much lower. 0x10 perhaps. And change:
err = sceNetInit(0x20000, 0x20, 0x1000, 0x20, 0x1000);
to have the two 0x20s be something more like 0x12.
That will ensure that your network thread is much higher priority than your main thread, so that network stuff will actually happen in the background. Then just do a sleep call for a few miliseconds and see what happens.