[SOLVED] Socket getting STUCK if data not sent continuously

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

Moderators: cheriff, TyRaNiD

Post Reply
KickinAezz
Posts: 328
Joined: Sun Jun 03, 2007 10:05 pm

[SOLVED] Socket getting STUCK if data not sent continuously

Post by KickinAezz »

After trying everything possible.. I decided I would post my problem here. Hopefully, I will recieve some help :D

My problem is Socket on PSP seem to act as Blocking or something I donot know... It seems to get "STUCK" if we donot continuosly send data(confirmed) or continuously recieve data from the server (my hypothesis, haven't tested).

-----

OK, To test I use this server http://bansky.net/echotool/ and you'll have to too.

To start

Code: Select all

echotool.exe  /p tcp /s 1000
PLEASE TEST THIS PSP Binary
---------------------------------------

1) It connects to first Access point in the network list.
2) You will see numbers scrolling on screen... This is to show that PSP isn't "stuck".
3) Press and KEEP HOLDING CIRCLE button.
4) Press for once,
SQUARE to connect to 192.168.2.4:1000 or
CROSS to connect to 192.168.2.5:1000
if your PC has someother IP address, please try manually setting the IP address to one of the above to diagnose my problem. Please donot let this stop you from trying....

5) The server program will recieve and keep recieving "[GOTCHA]" and send it back... It works. However,


Onto the Problem:
-----------------

Release the CIRCLE and you get stuck.

Close the TCP Server and psp gets "unstuck".

Why is this happening?
Anyone got any idea why this is happening?

#### Parts of Code#####

Code: Select all

sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); //0

    socksetting=1;
    sceNetInetSetsockopt(sock, SOL_SOCKET, SO_NONBLOCK, (int *)&socksetting, sizeof socksetting);
    socksetting= 500000; //half sec
    sceNetInetSetsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (int*)&socksetting, sizeof socksetting);
    sceNetInetSetsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (int*)&socksetting, sizeof socksetting);
 socksetting=1;
 sceNetInetSetsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (int*)&socksetting, sizeof socksetting);
 if(!initSocket(&name, ipaddr, port)) //simple ip,port setup code
 {
  pspDebugScreenPrintf("address conf problem\n");
        close(sock);
  return -1;
 }

 if&#40;connect&#40;sock, &#40;struct sockaddr *&#41; &name, sizeof&#40;name&#41;&#41; < 0&#41;


main&#40;&#41;
&#123;
for&#40;;;&#41;
&#123;
numhold=recv&#40;sockfd,&recvbuff,255,0&#41;;
        if &#40;numhold!=-1 && numhold!=0&#41;
        &#123;
        pspDebugScreenPrintf&#40;"<-&#40;%s&#41;",recvbuff&#41;;
        &#125;

if &#40;pad.Buttons & PSP_CTRL_CIRCLE&#41;
        &#123;
                if &#40;&#40;numhold=send&#40;sockfd,"Gotcha!\n",strlen&#40;"Gotcha!\n"&#41;,MSG_DONTWAIT&#41;&#41;==-1&#41;
                &#123;
                pspDebugScreenPrintf&#40;"->ERROR\n"&#41;;
                sceKernelDelayThread&#40;50000&#41;;
                &#125;
                else
                &#123;
                pspDebugScreenPrintf&#40;"->SENT\n"&#41;;
                &#125;
        &#125;
 sceDisplayWaitVblankStart&#40;&#41;;
&#125;
Last edited by KickinAezz on Fri May 16, 2008 7:21 am, edited 5 times in total.
Intrigued by PSP system Since December 2006.
Use it more for Development than for Gaming.
KickinAezz
Posts: 328
Joined: Sun Jun 03, 2007 10:05 pm

Post by KickinAezz »

In Brief: I need to be able to send / recieve at any time and NOT Continuously.

Thanks. Any ideas?
Intrigued by PSP system Since December 2006.
Use it more for Development than for Gaming.
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

Sounds like you need to be using select().

Good sockets stuff here: http://beej.us/guide/bgnet/output/html/ ... bgnet.html
KickinAezz
Posts: 328
Joined: Sun Jun 03, 2007 10:05 pm

Post by KickinAezz »

Insert_witty_name wrote:Sounds like you need to be using select().

Good sockets stuff here: http://beej.us/guide/bgnet/output/html/ ... bgnet.html
I think select() is for servers not clients?

Could you clarify?

EDIT: Solved.
Intrigued by PSP system Since December 2006.
Use it more for Development than for Gaming.
Post Reply