Code (glbasic) Select
// --------------------------------- //
// Project: iPodNet
// Start: Friday, April 13, 2012
// IDE Version: 10.244
// SETCURRENTDIR("Media") // go to media files
SYSTEMPOINTER 1;
SETSCREEN 480,320,1;
GLOBAL mx%,my%,mb1%,mb2%,clicked%;
GLOBAL server%,client%,lastip%,socktcp%,sock%;
GLOBAL ip$="178.208.199.151";
GLOBAL port%=21851;
GLOBAL msg%,readmsg%,connect%;
WHILE NOT KEY(1)
MOUSESTATE mx%,my%,mb1%,mb2%;
//create server or client
IF server=0 AND client=0
IF mb1>=1
IF mx<200//touch left side of screen to create server
CreateServer();
ELSEIF mx>280//touch right side of screen to create client
CreateClient();
ENDIF
ENDIF
ENDIF
TcpListen();
IF server=1
PRINT "ACTING AS SERVER",10,10,1;
ENDIF
IF client=1
PRINT "ACTING AS CLIENT",10,10,1;
ENDIF
IF connect=1
PRINT "CLIENT CONNECTED",10,50,1;
ENDIF
IF mb1=0
clicked=0;
ENDIF
SHOWSCREEN
WEND
FUNCTION TcpListen:
IF server=1//server checks for messages
readmsg=SOCK_TCPACCEPT(socktcp,lastip);
IF readmsg>=1
//client has connected
connect=1;
ENDIF
ENDIF
ENDFUNCTION
FUNCTION CreateServer:
sock=SOCK_INIT();
IF sock
socktcp=SOCK_TCPLISTEN(port);
DEBUG "SERVER:sock=ok ";
IF socktcp>=0
server=1;
DEBUG "SERVER:socktcp=ok ";
ELSE
DEBUG "SERVER:could not create sock ";
ENDIF
ENDIF
ENDFUNCTION
FUNCTION CreateClient:
sock=SOCK_INIT();
IF sock
socktcp=SOCK_TCPCONNECT(ip$,port,5000);
DEBUG "CLIENT:sock=ok ";
IF socktcp>=0
client=1;
DEBUG "CLIENT:socktcp=ok ";
ELSE
DEBUG "CLIENT:could not create sock ";
ENDIF
ENDIF
ENDFUNCTION
Can anyone please help with the above code. I cant verify whats wrong, well actually nothing is wrong because it works perfectly on PC, it just does not work on iPhone when I run it as server.
To clear matters hope this helps
PC Server - PC Client = Works perfect
PC Server - iPod Client = Works perfect
iPod Server - iPod Client = No way
iPod Server - PC Client = No way
Cant get this running on as iPod Server. Yes I have allowed for all ports on PC and iPod, it would not be working on PC then.
I have even disabled firewalls etc, but thats not the problem as it works on PC's, can anyone please help here?
Ill really be thankful.
Thanks
NOTE: Just run program in 2 separate instances, click left side of screen to act as server, and on other click right to act as client.
When you run client you receive msg on server side.