Network help

Previous topic - Next topic

Maxheadroom

Help, just trying to open a network port 23 (telnet) to a telnet server wake it up and receive the login prompt. However I am missing something as I just get a -1 error at the sock_send stage any suggestions?

Code (glbasic) Select
GLOBAL sock, port%, ip$,socktcp , socksend, sockread, ret$

port%= 23
ip$= "192.168.55.2"

start:

sock=SOCK_INIT();


socktcp=SOCK_TCPCONNECT(ip$,port%,5000);
DEBUG " setup connect= "+socktcp



socksend = SOCK_TCPSEND (port%, "wake up"+CHR$(13))
DEBUG "send:= "+socksend

sockread = SOCK_RECV (port%, ret$, 1024)
DEBUG " read error= "+ sockread+ " incoming packet="+ret$


SOCK_CLOSE (port%)

SOCK_SHUTDOWN
END


MrTAToad

What does NETGETLASTERROR$() report ?

Maxheadroom

The error reply came back and said:

Injection started

setup connect= 0send:= -110038 An operation was attempted on something that is not a socket.

did the read as well:

read error= -1 incoming packet=10038 An operation was attempted on something that is not a socket.

MrTAToad

I would think that the server is not listening, and thus a socket cant be created.

Kitty Hello

TCP_SEND not to the "port%", but to the "socktcp%" socket! ;)

Maxheadroom

working  :good:

start of a basic telnet program, it needs so checking but it works !

// --------------------------------- //
// Project: telnet
// Start: Wednesday, June 05, 2013
// IDE Version: 10.283


// SETCURRENTDIR("Media") // go to media files


GLOBAL sock, port%, ip$,socktcp , socksend, sockread, ret$

port%= 23
ip$= "192.168.55.2"

start:

DEBUG " START "
KEYWAIT


sock=SOCK_INIT();
DEBUG " int sockets= "+sock
KEYWAIT
socktcp=SOCK_TCPCONNECT(ip$,port%);
DEBUG " setup connect= "+socktcp
KEYWAIT


socksend = SOCK_TCPSEND (socktcp, "wake up"+CHR$(13))
DEBUG "send:= "+socksend
KEYWAIT
sockread = SOCK_RECV (socktcp, ret$, 1024)
DEBUG " read error= "+ sockread+ " incoming packet="+ret$
KEYWAIT

SOCK_CLOSE (port%)

SOCK_SHUTDOWN
END