Author Topic: Network help  (Read 2331 times)

Offline Maxheadroom

  • Mr. Drawsprite
  • **
  • Posts: 62
    • View Profile
    • http://www.hot-apartments.co.uk
Network help
« on: 2013-Jun-07 »
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
« Last Edit: 2013-Jun-07 by Schranz0r »

MrTAToad

  • Guest
Re: Network help
« Reply #1 on: 2013-Jun-07 »
What does NETGETLASTERROR$() report ?

Offline Maxheadroom

  • Mr. Drawsprite
  • **
  • Posts: 62
    • View Profile
    • http://www.hot-apartments.co.uk
Re: Network help
« Reply #2 on: 2013-Jun-07 »
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

  • Guest
Re: Network help
« Reply #3 on: 2013-Jun-07 »
I would think that the server is not listening, and thus a socket cant be created.

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10851
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Network help
« Reply #4 on: 2013-Jun-12 »
TCP_SEND not to the "port%", but to the "socktcp%" socket! ;)

Offline Maxheadroom

  • Mr. Drawsprite
  • **
  • Posts: 62
    • View Profile
    • http://www.hot-apartments.co.uk
Re: Network help
« Reply #5 on: 2013-Dec-02 »
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