forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[SOLVED] Socket getting STUCK if data not sent continuously

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
KickinAezz



Joined: 03 Jun 2007
Posts: 328

PostPosted: Thu May 15, 2008 7:51 am    Post subject: [SOLVED] Socket getting STUCK if data not sent continuously Reply with quote

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:

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:

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(connect(sock, (struct sockaddr *) &name, sizeof(name)) < 0)


main()
{
for(;;)
{
numhold=recv(sockfd,&recvbuff,255,0);
        if (numhold!=-1 && numhold!=0)
        {
        pspDebugScreenPrintf("<-(%s)",recvbuff);
        }

if (pad.Buttons & PSP_CTRL_CIRCLE)
        {
                if ((numhold=send(sockfd,"Gotcha!\n",strlen("Gotcha!\n"),MSG_DONTWAIT))==-1)
                {
                pspDebugScreenPrintf("->ERROR\n");
                sceKernelDelayThread(50000);
                }
                else
                {
                pspDebugScreenPrintf("->SENT\n");
                }
        }
 sceDisplayWaitVblankStart();
}

_________________
Intrigued by PSP system Since December 2006.
Use it more for Development than for Gaming.


Last edited by KickinAezz on Fri May 16, 2008 7:21 am; edited 5 times in total
Back to top
View user's profile Send private message
KickinAezz



Joined: 03 Jun 2007
Posts: 328

PostPosted: Thu May 15, 2008 8:03 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Insert_witty_name



Joined: 10 May 2006
Posts: 376

PostPosted: Thu May 15, 2008 6:25 pm    Post subject: Reply with quote

Sounds like you need to be using select().

Good sockets stuff here: http://beej.us/guide/bgnet/output/html/singlepage/bgnet.html
Back to top
View user's profile Send private message
KickinAezz



Joined: 03 Jun 2007
Posts: 328

PostPosted: Thu May 15, 2008 8:10 pm    Post subject: Reply with quote

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

Good sockets stuff here: http://beej.us/guide/bgnet/output/html/singlepage/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.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group