Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
PixelToast

TCPNet

Recommended Posts

Rj9rH3s.png

https://github.com/P-T-/TCPNet


This API allows for infinite cross range, cross server communication with the internet card.
 
It uses a external Lua server which requires luasocket (should work on both 5.1 and 5.2)
on ubuntu/debian you can use apt get install luarocks and then luarocks install luasocket
on windows: https://code.google.com/p/luaforwindows/downloads/list
others you will have to find/compile binaries
 
once you have a server set up and forwarded you can access it in OC with your computer's external IP (or localhost if you changed the tcp blacklist)
 

API

local handle=tcpnet.new([ip[,port]])
connects to the server, ip defaults to localhost and port defaults to 25476
handle:receive([timeout[,port]])
returns port,data
or just data if the port parameter is given
handle:send(port,data)
sends data to port
handle:open(...)
opens ports
handle:close(...)
closes ports
event "tcpnet_message",port,data

Protocol

every message and response is a table serialized
ports can be strings or numbers
it does serialize the data, but because computer.pushSignal doesnt support tables, my api wont allow them
but it is really easy to write your own api
{"send",port=port,data=data}
sends data to everyone listening on port
{"open",ports={[port]=true,[port]=false}}
open/close ports
{"message",port=port,data=data}
you receive this when you get a message
Link to post
Share on other sites

About luasocket, I know that you can install luarocks on OS X with both homebrew and macports, so you can run the server from OS X as well. 

 

Also, I don't really get what you mean with protocol. Is that what is returned by event.pull? 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.