TCP device

Anything QL Software or Programming Related.
Post Reply
Martin_Head
Aurora
Posts: 852
Joined: Tue Dec 17, 2013 1:17 pm

TCP device

Post by Martin_Head »

Has anyone tried/managed to get QPC2 on two networked PC's to talk to each other using the TCP_ device?

I know there was an article in Quanta some time ago about using the device to access email, or it may have been Newsgroups (cant quite remember). I've had a quick try, but with no success.

If someone has done it, what port numbers did you use? Is it just a case of doing something like OPEN#4,"tcp_172.1.0.20:123" on each PC then PRINT# and INPUT# between them? Can you do things like COPY_N an html file from QPC2 to a web browser running on the other PC?

P.S. I'm not entirely sure that the two PC's I have been using are actually talking to each other correctly, which may be why I am having trouble.

Martin.


User avatar
tofro
Font of All Knowledge
Posts: 2700
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: TCP device

Post by tofro »

Martin,

There was a (very good, with example program and everything) article in QL Today on how to get CD information from the central CD Title and Track database on the internet from Wolfgang Lenerz. I don't quite recall the exact issue, but the QL Today Index on Dilwyn's site should know.

Tobias


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
Martin_Head
Aurora
Posts: 852
Joined: Tue Dec 17, 2013 1:17 pm

Re: TCP device

Post by Martin_Head »

Thanks for the suggestion. Had a quick look through volumes 6 to 15 on Dilwyn's site, but it did not leap out at me. Might have to look the hard way, but should not have to go to far back as the tcp_ device is quite recent. But mainly I'm interested in trying to get two QPC's talking to each other. Just wondering if its possible?

Martin.


User avatar
tofro
Font of All Knowledge
Posts: 2700
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: TCP device

Post by tofro »

Martin,

it's Volume 16, issues 1 and 2, so you were close ;)

And, no, it's not so simple as just open and close. Connecting to an Internet server is much easier than providing the server yourself.

On a second look (I was interested, because I've only done that in C up to now), it seems to be impossible to create a TCP server with SuperBASIC only. You can create the socket, even bind() it, but i was not able to find a way to accept() on the server side. Toolkits hat allow you to call QDOS traps from Basic (I think the DIY TK had one) would come to help here.

On the other hand, you could create a peer-to-peer UDP connection (which would work from S*BASIC), but then you can't call sendto() or rcvfrom() without the help of such a TK above.

Connecting to an existing server, however, is perfectly possible (and quite straightforward) from S*BASIC. Simply do a

Code: Select all

socket = FOP_IN ('tcp_hostname:portno')
REPEAT
  Print #socket, "HELLO"
  Input #socket,a$
  print a$
END REPeat

Tobias


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
Ralf R.

Re: TCP device

Post by Ralf R. »

Hasn't Jonathan Dent realised that it SB?


User avatar
tofro
Font of All Knowledge
Posts: 2700
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: TCP device

Post by tofro »

Ralf,

Jonathan, has, AFAIK, implemented a TCP/IP / SLIP interface (and some clients like a POP3 client in C). TCP/IP is already there in QPC2, and, even better, over any media.

Martin's question looks more into usage of such a driver and whether that would be feasible using an S*BASIC program only. With C68, it's kind of easy - All the libraries and system calls are there and supported. With S*BASIC, it's not that easy, because some system calls into the driver are not accessible.

Tobias


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
Martin_Head
Aurora
Posts: 852
Joined: Tue Dec 17, 2013 1:17 pm

Re: TCP device

Post by Martin_Head »

The idea, and it is purely an idea, was that if you could get two QPC's to talk to each other using the tcp device driver. Then you might be able to get a QL Network going.

I was only using SuperBASIC because it's easiest for testing, that I could get them talking. So from what's said above, SuperBASIC only really likes talking to a server of some kind. But it may possible using C or Assembler, using the right system calls and traps?

I will state now that my knowledge of networks and network protocols is small to say the least.

Martin.


User avatar
tofro
Font of All Knowledge
Posts: 2700
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: TCP device

Post by tofro »

Exacly.

TCP/IP networking strongly distinguishes between a Server and a Client (wherever it's running, Internet or private network).

The system calls to the driver needed to program a Server are not accessible from SuperBASIC (just because nobody has yet programmed a Toolkit to include those calls). Clients, however, can easily be programmed in S*Basic using existing keywords (see the example I was referring to in QL Toady).

TCP/IP Servers, on the other hand, can be programmed in C68 - There's a library that exposes all the calls needed, closely resembling to the UNIX way of things, so you can even easily port Unix/Linux networking server examples to QPC2 or uQLX. Apart from C68, I know of no other language for the QL that implements those calls.

Tobias


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
swensont
Forum Moderator
Posts: 252
Joined: Tue Dec 06, 2011 3:30 am
Location: SF Bay Area
Contact:

Re: TCP device

Post by swensont »

To add to the mix, Perl has some network features. I wonder if the QDOS port of Perl will work with the TCP driver. Since the Perl port was done years before the TCP driver, it might be possible that the network code was left out of the port. I'll leave the rest as an exercise for the reader.

Tim


Post Reply