![]() |
|
TCP/IP Socket Programming - Printable Version +- Small Basic Forum (https://litdev.uk/mybb) +-- Forum: Small Basic (https://litdev.uk/mybb/forumdisplay.php?fid=1) +--- Forum: Extensions (https://litdev.uk/mybb/forumdisplay.php?fid=3) +--- Thread: TCP/IP Socket Programming (/showthread.php?tid=424) |
TCP/IP Socket Programming - Juergen - 07-14-2025 Hello, i want to program a TCP/IP Socket to establish an ethernet communication, just to transmit some values over ethernet. I look for some example codes or API or libraries in litdev. Who can give me a hint ? RE: TCP/IP Socket Programming - litdev - 07-14-2025 For http Web requested look at ldnetwork. For network communications look at ldserver and ldclient. I am away from home at present without pc, but I think there are some samples for these with the extension download. If you use sb prime then you can also search extensions. Not sure exactly what you are after, but I think the ldserver ldclient is most likely. RE: TCP/IP Socket Programming - Juergen - 07-16-2025 Thanks for your help, i think LDServer and LDClient is what i need. Can you give me a link to some examples where they are used ? Thanks RE: TCP/IP Socket Programming - AbsoluteBeginner - 07-16-2025 (07-16-2025, 09:40 AM)Juergen Wrote: Thanks for your help, i think LDServer and LDClient is what i need. Can you give me a link to some examples where they are used ? Hello! Here is a link to the examples folder: https://github.com/litdev1/LitDev/tree/master/Samples/client-server RE: TCP/IP Socket Programming - Juergen - 07-25-2025 I am programming a program for my Pc connecting to a device that control a model railway. I think this device is the server and my PC is client. In the description of this device it is declared that it has an ethernet with a IP 192.168.2.20 and a recieve Port 15730 and a send Port 15731. Now my question : do i have to connect to both ports with : LDClient.Connect( "192.168.2.20:15730", "False" ) and LDClient.Connect( "192.168.2.20:15731", "False" ) , or only connect to the recieve Port 15731 ? RE: TCP/IP Socket Programming - litdev - 07-25-2025 Hi, I've only used the Client/Server with both client and server being Small Basic programs, so not fully sure. If the server is using different ports to send and receive data, then I think you may need 2 separate SB programs to connect to each. I guess I would start by tring to send a message to 192.168.2.20:15731 in a simple SB program and check if this gets through. If this works it is a good start. To receive messages use the LDClient.ServerMessage event and property LDClient.LastServerMessage, but I think this will have to be a separate SB program connected to 192.168.2.20:15730. If these work independently, then I would think that one of the 2 SB programs would be the master and the other would be a slave that is controlled by the master, perhaps through a common file. RE: TCP/IP Socket Programming - Juergen - 07-25-2025 thanks for information, the device i am connected with i can not modify only i can put in an other ip adress , nothing more. And on my pc i have only one program with i want to send and recieve messages. so i thing i have to connect to both ports if i understand you correctley. RE: TCP/IP Socket Programming - litdev - 07-25-2025 Yes, but I am only guessing to some extent. I would test the sending and receiving separately on very small test SB programs using the different ports as I suggested. Once these both work independently, we can consider how to use both together - I suspect this will have to be 2 SB programs, but I can help suggest ways to run them together when you get to that point. RE: TCP/IP Socket Programming - Juergen - 07-25-2025 can you tell me if this syntax is correct ? If LDClient.CheckServer( "192.168.0.96:15731" ) = "AVAILABLE" THEN LDClient.Connect( "192.168.0.96:15731", "TRUE" ) CS_Recieveport_connected = 1 EndIf RE: TCP/IP Socket Programming - litdev - 07-25-2025 Yes, that should work (syntax is right if it compiles - whether it does what you expect is a different thing - that depends what you expect!) - I wouldn't use the "True" on the Client connection - that is for use with LDServer. Before even using the If test, just print out the result - you can add frills when the basics work. Code: TextWindow.WriteLine("Testing...")If it fails there is a few seconds delay where a timeout is applied. Or you could just check the client connection: Code: result = LDClient.Connect("192.168.0.96:15731", "False") |