Qbasicnews.com

Full Version: FB TCP/IP routines?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I read in the documentation that prior to creating FreeBasic, Andre Victor created libraries which enabled QuickBasic to communicate over the internet. I had always wondered whether or not that was possible.

Where can I find these libs for download, as well as any documentation on how to use them? I have never learned TCP/IP stuff directly, but am hoping I can figure it out as I go for simple back-and-forth text transmission purposes.

Also, are there any pre-made libs/subs etc that people have made for FreeBasic that simplify or automate net communication routines? Or at the least, instruction files on how to do it?
Thank you! Are there are good basic tutorials anywhere for an experienced BASIC programmer but absolute newbie to Winsock stuff, on how to do tne with the other? How to use that DSOCK from either QB or FB?
well Dsock no good for FB well maybe it might work with FBDOS but that even then FBDOS sets a protect mode so Dsock might not work with it.


if your using Freebasic use the windows distro of it and use winsock.

the best guide to winsock i know of is Beej's guid to network programming.

http://www.ecst.csuchico.edu/~beej/guide/net/html/

this will teach you plain old BSD which is more or less universal from platform to platform (well windows makes you call a few init stuff and some cleanup stuff at the end)

this tutorial is in C but you should be able to get the idea. it should also apply to Dsock since Dsock is just a interface driver for winsock so the API should be the same as winsock and there for compatible with BSD
Thanks! I've been looking over that turorial.. unfortunately the author loses me as soon as he starts talking about "structs" and "byte orders". I'm really, really, really unfamilar with TCP, as in, I've never heard of it before or anything having to do with it, other than the fact that it means internet communication.

The C notation probably doesn't help me grasp it either since I'm totally unfamiliar with C.

Is there somewhere I can start even more basically than that? I understand the idea of sockets, but I have no idea what structs or bytes are (well, I sort of know what a byte is, but not in relation to data packets or anything like that.)

I am trying to learn in the simplest terms possible, how in QB to basically do something like:

message$="Hey, how are you"
send message$ to IP Address 000.000.000.000 on port 0000

Assuming that the computer at that IP address is running the right program and listening on the right port at the time, to receive the message.

I know the coding for that is a lot more involved, but I need to learn from the very ground up how to code it. Like I said, I've never heard of a SOCK before today, so it's all totally beginner stuff for me.

Any pointers?
ah just ignore the byte order stuff for the most part just know you have to use hton for the port number.


and the C notation isn't bad for the most part you should be able to see how the API is used for the most part to get an understand of how it all works.

the basic system kind of works like this for Clients

fill in your socket basic structor and call connect and todat connection made thenuse send and recv to get data from the server and to send it.

gets a bit trickey when you want to do non blocking sockets which mean you don't want the program to block when recving data which means the program will hang untill some data comes in.

doing non blocking can be kind of trickey for sending and reciving data its kind of easy because you can use the FD_ macro set along with Select aka in FB as Socket_select to do polling on a socket descriptor to see if it ready to be read from or to send data to.

but to do non blocking with things like Connect you have to twick the Socket descriptor.
Ay yi yi.... thanks for the help and description. I can see that I'm going to have to read up on this stuff for a good several weeks before I understand or can use any of it.

These things must be very simple and familiar to many people, but for me just figuring out how to link the DSOCK lib to my QBasic program is going to take a few days. I don't know if I can just use an #Include statement or some other technique for linking.

Anyway, I don't mean to try to use you as my personal instructor, so I'll plow through the documentation as well as I can and see how it works out.

I will say though that if anyone has any example code of QBasic doing really simple connection stuff, I'd love to take a look at it for reference. That tutorial page shows using "int" for socket description, and as far as I know "int" isn't a command in QB except for returning the integer value of a variable.
if you're stuck on something, I know WT0990 has been dabbling in it, as well as myself, and i'm sure others, so don't be afraid to ask questions

oz~
Hehe, thanks! By now I've got it all working and have posted an example direct-client-to-client two-way simultaneous chat program I wrote in the projects area, as a sort of reference guide/tutorial for others dabbling as well.