Community Forum

How Network Functions Work

Forum Overview >> Scripting

CategoryScripting
Created26.06.2014 09:30


Zach Wyman (Unknown) 26.06.2014 09:35
I was wondering if there were any examples of code or mods that show how the network functions work. I'm trying to communicate between FS and another program using sockets and the network functions in the GDN API. I was able to start up a server (I think) with the netStartup function, but I'm not sure how to tell if my program is connecting to it or what to connect to. In the arguments of the function, I have put the address as localhost and 127.0.0.1 and used the port number 5000. When I type netstat -an into the console, it shows that the address 0.0.0.0:5000 is being used, but not 127.0.0.1:5000. Any help there? Also, when I try to use either the netConnect function or the packetReceived function, I get the error 'attempt to call global "netConnect" (a nil value)'. Is there anything that I need to do that I'm forgetting to do? Also, is there a way to import libraries and use them in your mods? The extension library LuaSocket looks very interesting. Thanks for the help and let me know if I need to clarify.

Zach Wyman (Unknown) 26.06.2014 15:01
Another thing, how is the packetReceived callback function supposed to work? I have it implemented as -

print(netStartup(5, 15, "127.0.0.1", 5000, "packetReceived", AutoDriver))
and then
function AutoDriver:packetReceived(packetType, timeStamp, streamId)
print("Hello!!")
end;

just to test it and see if anything is coming through, but it doesn't seem to be working. Am I doing this completely wrong or is there a problem with the packet exchange where the game is not getting the packets? I can't tell if the game is not recognizing that it is receiving the packets or the game is just not receiving the packets.


Manuel Leithner - GIANTS Software 30.06.2014 11:30
hi,

currently it's not possible to connect with an external client to a server created with netstartup.

Zach Wyman (Unknown) 30.06.2014 13:53
Is there any networking possible through the functions in the API? What possibilities exist to exchange information between the game and another program? I'm currently doing it through file-based, but it is fairly inefficient and I was wondering if there were any better alternatives. Thanks again!

Emil Drefers (Unknown) 04.07.2014 08:18
Hi,

as my colleague has stated before there are no possibilties to connect the Farming Simulator to an external program by using network functions.
The only possibility is file based, as you already know.

Sorry that i can't tell you any news, but the locked network functions are implemented due to security reasons.

Best,
Emil




Note: Log in to post. Create a new account here.