Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.acorn.programmer > #1659 > unrolled thread

Networking in Basic

Started by <news@iank.org.uk>
First post2012-04-21 22:33 +0100
Last post2012-05-05 10:33 +0100
Articles 4 — 4 participants

Back to article view | Back to comp.sys.acorn.programmer


Contents

  Networking in Basic  <news@iank.org.uk> - 2012-04-21 22:33 +0100
    Re: Networking in Basic Sprow <news@sprow.co.uk> - 2012-04-21 15:11 -0700
    Re: Networking in Basic Alan Adams <alan@adamshome.org.uk> - 2012-04-22 12:40 +0100
    Re: Networking in Basic "rojo@riscos.org" <rojo@riscos.org> - 2012-05-05 10:33 +0100

#1659 — Networking in Basic

From <news@iank.org.uk>
Date2012-04-21 22:33 +0100
SubjectNetworking in Basic
Message-ID<528414de58news@iank.org.uk>
Hello All
I am trying to add to an existing Basic programme the ability to read data
from a port across a network. In the past I would of used Justin
Fletcher's EasySockets module but this is not 32bit. If anyone can point
me in the direction of an equivalent or a suitable Basic library I would
be eternally grateful. It only has to read a few bytes of data and speed
is not really an issue.

Regards
Ian K

[toc] | [next] | [standalone]


#1660

FromSprow <news@sprow.co.uk>
Date2012-04-21 15:11 -0700
Message-ID<02051099-28cb-4f29-9b83-91309df99812@l3g2000vbv.googlegroups.com>
In reply to#1659
On Apr 21, 10:33 pm, <n...@iank.org.uk> wrote:
> I am trying to add to an existing Basic programme the
> ability to read data from a port across a network.

[snip]

> It only has to read a few bytes of data and speed
> is not really an issue.

Though you don't want the hardware bit, if you go to
  http://www.sprow.co.uk/bbc/masternet.htm
and scroll down to the downloads you'll find a simple web server (for
TCP) and NTP client (for UDP) written in BASIC.

Within the program there are functions to manipulate sockets - you can
safely ignore the BBC Micro equivalents!
Sprow.

[toc] | [prev] | [next] | [standalone]


#1665

FromAlan Adams <alan@adamshome.org.uk>
Date2012-04-22 12:40 +0100
Message-ID<757a628452.Alan.Adams@laptop.adamshome.org.uk>
In reply to#1659
In message <528414de58news@iank.org.uk>
          <news@iank.org.uk> wrote:

> Hello All
> I am trying to add to an existing Basic programme the ability to read data
> from a port across a network. In the past I would of used Justin
> Fletcher's EasySockets module but this is not 32bit. If anyone can point
> me in the direction of an equivalent or a suitable Basic library I would
> be eternally grateful. It only has to read a few bytes of data and speed
> is not really an issue.

I'm ssuming the existing program is a Wimp program. If not, I'm not 
sure you can do it.

It will make a big difference in your code whether you can block 
waiting for the message, or whether you need the computer to respond 
to user input while waiting for data. The latter is a bit more 
complicated to code. Assuming the latter...

First you need to know whether the data is being sent using TCP or UDP 
packets. There's a fundamental difference between the way these two 
work.

UDP (unreliable datagram protocol) doesn't guarantee to deliver the 
data, but if is is delivered then the message arrives in a single 
piece.

TCP does guarantee to deliver the data (which is why it is the more 
common form of transport) but the data may be fragmented, arriving in 
several pieces.

For TCP generally you will want a handler called from wimp_pollidle 
which checks whether there is anything received. If there is, copy it 
into a buffer (NOT a BASIC string, because it may be too long), adding 
to what may already be in the buffer and set a flag for the main 
program to know something has arrived.

For TCP you will need a way to know whether the buffer contains a 
complete message, and where the start and end are. If you have control 
over the sender, it's a case of wrapping the message in markers, for 
example a character or string that the message itself is guaranteed 
never to contain. If not, you need to know exactly what is being sent, 
so you can search the buffer for it.

Once your complete message is in the buffer, you can process it. That 
initial processing will also need to be in a Wimp_Pollidle call, as 
the programme will have to wait for data.

I would strongly advise getting and using !Reporter, if you don't 
already. Debugging this stuff can be tricky.

-- 
Alan Adams, from Northamptonshire
alan@adamshome.org.uk
http://www.nckc.org.uk/

[toc] | [prev] | [next] | [standalone]


#1693

From"rojo@riscos.org" <rojo@riscos.org>
Date2012-05-05 10:33 +0100
Message-ID<528b08b279rojo@riscos.org>
In reply to#1659
Thanks for your replies. That's got me pointed in the right direction.

Regards
Ian K

[toc] | [prev] | [standalone]


Back to top | Article view | comp.sys.acorn.programmer


csiph-web