SWI Socket_Connect
John Sandgrounder (1650) 574 posts |
I am writing some routines in Basic to communicate from one Pi to another using TCP/IP. I have the ‘receive’ side working without needing EasySockets. I am using code based on Stuart Brodie’s !HTTPServr from 1996. His code serves as a very useful guide to using the socket SWIs in Basic. However, I am having trouble with the ‘send’ side as I can not find any documentation for the Socket_Connect SWI. As I am writing in basic, I need the information in the same style in which all of the other SWIs are documented in the PRMs. Does anyone know of socket documentation in such a format, as I can not convert the info I have found for programs written in ‘C’. Alternatively, an example of somes lines of Basic code would be very useful. I think that once I have a connection established, then I should be OK with the rest. |
Steve Pampling (1551) 8170 posts |
Have a peek at AntiSpam the uncompressed source BASIC is in the package – it’s the “Source” file in !AntiSpam.Resources. |
Robert Hampton (1923) 57 posts |
I was going to point you to the PRMs on ROL’s web site, but it seems the Socket documentation there also assumes C. However, StrongHelp comes to the rescue! Download the InetSocket manual from http://www.riscos.info/downloads/stronghelp/manuals/inetsocket106.zip and I suspect the info you need will be in there. |
John Sandgrounder (1650) 574 posts |
Thank You both. I have now got a bit of reading to do! EDIT – 1 hour later – Six lines of basic in a task window and I now have simple one line messages being sent from one Pi to another. Having both sets of information made it all fit together very nicely. :) |
Rob Heaton (274) 515 posts |
John, please would you share your BASIC code? |
David Feugey (2125) 2709 posts |
Same here… would be a good candidate for the BBC Basic contest :) |
Steve Pampling (1551) 8170 posts |
I recommended AntiSpam as a source of example code as pretty much everything I’ve forgotten1 about socket coding came from the early versions of AntiSpam or the PRMs and mostly from AntiSpam.
I’m impressed with the 1 hour bit, as I recall it took me a whole weekend to get working code doing DNS queries. 1 A few years back, probably close to 10 |
John Sandgrounder (1650) 574 posts |
The 1 Hour was just to get a simple socket connection to another Pi on my local network. DNS is a whole new exercise. My six lines of code for my test assumed that I had software (on port 9003) at the receiving end (IP address 10.0.128.116) to deal with the incoming data. The six lines were:
If you have access to the raw access logs on a local web server then the following code can be verified by looking at the web server access log. It will generate a 404 error if the cgi script does not exist. The program will need to be run in a Task Window because of the blocking socket. Non-blocking code in a Wimp Task is also a whole new exercise (which I am now working on – and it will take longer than 1 hour).
|
David Feugey (2125) 2709 posts |
Hope to see code to get content of a webpage. The beginning of a very cool code to make apps based on web services. |