Winsock error 10035

Previous topic - Next topic

Turbo TURTLE

Hi... Everybody...

I am very new on writing software with GLBASIC. Actually I am trying to write a TCP based software. But I have some complaints.

I found a test routine on forum for socket programing. But when I try it I face with an ERROR coded 10035. When I debug it, I saw that   SOCK_TCPACCEPT() command creates this error code. On the other hand there is no error on the client side. It sends message without any problem. I need help.

Here is TEST routine.

Code (glbasic) Select

SYSTEMPOINTER 1;
SETSCREEN 480,320,1;

GLOBAL mx%,my%,mb1%,mb2%,clicked%;
GLOBAL server%,client%,lastip%=2852037848,socktcp%,sock%;
GLOBAL ip$="169.254.164.216";
GLOBAL port%=21851;
GLOBAL msg%,readmsg%,mssg$="HELLO WORLD",length%,connect%;
GLOBAL rv%,readport=0;
LOADFONT "smalfont.png", 1
SETFONT 1


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

DEBUG "SERVER="+ server +     "CLIENT="+client + "CONNECT=" + connect + "    ";

IF server=1
// rv% = SOCK_RECV(socktcp, mssg$,100)
// PRINT "SOCK TCP="+ socktcp + "   MESAJ DURUMU="+rv%,0,200
// IF rv% > 0
// PRINT mssg$,200,200
// ELSE
// mssg$ = NETGETLASTERROR$()
// DEBUG mssg$
// ENDIF
ENDIF

IF client=1
MOUSESTATE mx%,my%,mb1%,mb2%
IF mb2% = 1
rv% = SOCK_TCPSEND (socktcp, mssg$)
PRINT "LENGTH OF MESSAGE=" + rv%,0,220;
ENDIF
ENDIF



SHOWSCREEN
WEND
SOCK_CLOSE(socktcp)
END

FUNCTION TcpListen:
IF server=1//server checks for messages
readmsg=SOCK_TCPACCEPT(socktcp,lastip);
mssg$ = NETGETLASTERROR$()
DEBUG "    SENT SOCKET2 NO=" + socktcp + "    RECEIVED SOCKET NO=" + readmsg + "    ERROR=" + mssg$
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 " + "    SENT SOCKET1 NO=" + socktcp;
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


I have also a question does GLBASIC allows binary communication via network?
Thanks in advance.

Edit: Oh lookie, code-tags! (please use them for code, makes easier reading) /Moru

matchy

#1
The issue here is filtering null TCP acceptance (which has been tested).  8)
Code (glbasic) Select

readmsg=SOCK_TCPACCEPT(socktcp,lastip)
IF readmsg > -1
// allow connect
ELSE
// no request
ENDIF

Moru

Not everyone are perfect with English. You would be surprised to learn how many coders that use google translate to speak to others over the net. This can cause very rough language sometimes, totally different tone to what the user was expecting to say.

Turbo TURTLE

Thank you so much Moru. Actuall my English is not so bad. I sent this post very early morning after spending four hours on Socket programing.

Anyway there is stil no success and I need help. I have also a question. Does GLBASIC allow binary communication via network?

Thanks in advance...



Kitty Hello

Yes, you can pack binary data in a string and send it. Theres a function on the forums that does what netwebget does.

Turbo TURTLE


"Yes, you can pack binary data in a string and send it. Theres a function on the forums that does what netwebget does. "

Thank you Kity Hello...

I undestood that we have to convert binary data to ASCII codes to send. But we can not send it as it is. For example we can not send an exe file.

But to do this, I have to create a socket connection first. Of course without error 10035.

matchy

#6
I was just wondering if my code helped.  :|

Turbo TURTLE

"Humor > grammar. Thank for the feedback TT. I test for you good."

Are you still at grammar? Ok... No problem. Stay there...

erico

Me humor) )grammar dont worry about...it gets even worse on touch gadgets.
Keep up the good topic ;)

matchy

Sorry, I got a false on that SOCK_TCPACCEPT().  :O =D