{"id":70054,"date":"2026-06-04T02:41:48","date_gmt":"2026-06-03T23:41:48","guid":{"rendered":"https:\/\/vpesports.com\/minecraft\/mods\/figurasocketplugin\/"},"modified":"2026-06-04T02:41:48","modified_gmt":"2026-06-03T23:41:48","slug":"figurasocketplugin","status":"publish","type":"mod","link":"https:\/\/vpesports.com\/minecraft\/mods\/figurasocketplugin\/","title":{"rendered":"SocketPlugin"},"content":{"rendered":"<p>### VERY WORK-IN-PROGRESS<\/p>\n<p>A figura addon that allows you to open and use TCP sockets.<\/p>\n<p>### You can contact me at `ktzukii` on Discord if the mod crashes your game, or doesn&#8217;t work as intended.<br \/>\n#### (please attach the logs on the message, if not you&#8217;re getting a &#8220;invalid, read description&#8221;)<\/p>\n<p>## Documentation:<\/p>\n<p>### SocketAPI (global `socket`)<\/p>\n<p>**These functions WILL return nil if the client (game) running the avatar (your scripts and model) is not the host (eg. your game will return a `LuaSocket` instance, others will return `nil`.)**<br \/>\n**So please add host checks on your socket scripts, otherwise your avatar will error on other clients, and will cause unneccesary trouble and confusion.**<\/p>\n<p>`SocketAPI:newSocket(String host, Number port) -> LuaSocket`<br \/>\nOpens a new socket, will print errors in log or throw vm error.<\/p>\n<p>`SocketAPI:newWebsocket(String host, Number port) -> LuaWebsocket`<br \/>\nOpens a new websocket, will print errors in log or throw vm error.<\/p>\n<p>`SocketAPI:closeAllSocket()`<br \/>\nClose all sockets on the current avatar<\/p>\n<p>`SocketAPI:closeAllWebsocket()`<br \/>\nClose all websockets on the current avatar<\/p>\n<p>`SocketAPI:closeAll() -> nil`<br \/>\nCloses all sockets and\/or websockets on the current avatar<\/p>\n<p>### LuaSocket<\/p>\n<p>`LuaSocket:send(String data) -> nil`<br \/>\nSends data, limited to strings due to how I wrote this mod. (working on changing that)<\/p>\n<p>`LuaSocket:recv() -> string`<br \/>\nRecieves data, also limited to strings. (see above)<\/p>\n<p>`LuaSocket:hasData() -> boolean`<br \/>\nGets whether or not there is a message to be received, which can then be gotten by `LuaSocket:recv()`<\/p>\n<p>`Luasocket:close() -> nil`<br \/>\nCloses the socket, cleanly.<br \/>\n**Sockets close automatically on avatar destroy\/reload, but it&#8217;s not a clean close.**<\/p>\n<p>### LuaWebsocket<br \/>\n**Websockets are known to be buggy at this time.**<\/p>\n<p>`LuaWebsocket:send(String data) -> nil`<br \/>\nSends data, limited to strings due to my understanding of Java.<\/p>\n<p>`LuaWebsocket:recv() -> string`<br \/>\nRecieves data, also limited to strings. (see above)<\/p>\n<p>`LuaWebsocket:hasData() -> boolean`<br \/>\nGets whether or not there is a message to be received, which can then be gotten by `LuaWebsocket:recv()`<\/p>\n<p>`LuaWebsocket:close(String reason) -> nil`<br \/>\nCloses the socket, cleanly.<br \/>\n**Sockets close automatically on avatar destroy\/reload, but it&#8217;s not a clean close.**<\/p>\n<p>## Examples:<br \/>\n**This mod can interact with any TCP socket or websocket, not just python&#8217;s.**<\/p>\n<details>\n<summary>Python &#038; Lua interaction (Socket)<\/summary>\n<p>### Python server<br \/>\n&#8220;`python<br \/>\nimport socket,json,threading<\/p>\n<p># 127.0.0.1 restricts it to only your network, 0.0.0.0 lets anyone connect;<br \/>\n# only if the port is open (forwarded), otherwise it won&#8217;t work.<br \/>\n# (check https:\/\/portforward.com\/ for help, this is not related to my mod.)<br \/>\nHOST,PORT=&#8221;127.0.0.1&#8243;,9985<br \/>\n# recommended to use high port numbers, anything above 1000<\/p>\n<p>def client(sock:socket.socket,addr:tuple[str,int]):<br \/>\n    # send stuff, the socket can only recieve strings, limitation of the mod right now.<br \/>\n    # im working on expanding it to send more types, like tables\/dicts, etc.<br \/>\n    while True:<br \/>\n      try:<br \/>\n        raw:bytes=sock.recv()<br \/>\n      except: pass<br \/>\n      sock.send(raw)<br \/>\n      # close the connection after the message, no reason to keep it open<br \/>\n      sock.close()<br \/>\n      break<\/p>\n<p>    # what i would use if it was a server instead of a echo<br \/>\n    # while True:<br \/>\n    #     try:<br \/>\n    #         raw:bytes=sock.recv()<br \/>\n    #         data:dict=json.loads(raw.decode())<br \/>\n    #     except: pass<br \/>\n    #     break<\/p>\n<p>def run():<br \/>\n  with socket.create_server((HOST,PORT)) as server:<br \/>\n    # make a loop so that it runs infinitely<br \/>\n    while True:<br \/>\n        # waits until a client connects THEN continues with running past this point<br \/>\n        sock,addr=server.accept()<br \/>\n        # sock : tcp socket<br \/>\n        # addr : tuple[host,port]<\/p>\n<p>        threading.Thread(<br \/>\n           target=client,<br \/>\n           args=[sock,addr])<\/p>\n<p>if __name__==&#8221;__main__&#8221;:<br \/>\n  run()<br \/>\n&#8220;`<\/p>\n<p>### Lua client<br \/>\n&#8220;`lua<br \/>\nif not host:isHost() then<br \/>\n    &#8212; dont run the rest of the script if the client running the avatar is not the host<br \/>\n    return<br \/>\nend<\/p>\n<p>&#8212; `127.0.0.1` == `localhost` (`localhost` gets autotranslated into `127.0.0.1`)<br \/>\nlocal sock=socket:newSocket(&#8220;127.0.0.1&#8221;,9985)<br \/>\n&#8212; socket:newSocket returns nil if the client running the avatar is not host;<br \/>\n&#8212; so we avoid errors via the above host check.<br \/>\n&#8212; socket:newSocket returns nil if the connection failed.<\/p>\n<p>&#8212; check if the socket did open<br \/>\nif not sock then<br \/>\n    print(&#8220;couldnt connect, check if your server is running&#8221;)<br \/>\n    &#8212; and then return to stop errors if it didnt open<br \/>\n    return<br \/>\nend<\/p>\n<p>&#8212; register a tick event (function runs every tick)<br \/>\nevents.tick:register(function()<br \/>\n    &#8212; check if the socket has data<br \/>\n    if sock:hasData() then<br \/>\n        local raw=sock:recv()<br \/>\n        &#8212; then print said data<br \/>\n        print(raw)<br \/>\n    end<br \/>\nend)<br \/>\n&#8220;`<\/p>\n<\/details>\n<p>There are no more examples as of writing.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A Figura Addon that allows TCP sockets and more.<\/p>\n","protected":false},"featured_media":70055,"template":"","meta":{"_minecraft_slug":"figurasocketplugin","_minecraft_project_id":"RL7e9XCk","_minecraft_author":"Vaediam","_minecraft_license":"MIT","_minecraft_downloads":49,"_minecraft_follows":2,"_minecraft_client_side":"required","_minecraft_server_side":"unsupported","_minecraft_storage_type":"zip","_minecraft_archive_name":"figurasocketplugin.zip","_minecraft_size_bytes":81217,"_minecraft_version_count":7,"_minecraft_updated_at":"2026-05-16T13:54:40.090064Z","_minecraft_date_created":"2026-05-03T02:54:07.917164Z","_minecraft_date_modified":"2026-05-02T09:47:58.574730Z","_minecraft_project_url":"https:\/\/modrinth.com\/mod\/figurasocketplugin","_minecraft_icon_attachment_id":70055,"_minecraft_imported_at":"2026-06-03T23:41:49+00:00","_minecraft_import_hash":"cf8e37030a284227c130a37581983943","_minecraft_versions":"","_minecraft_links":"","_minecraft_gallery":"","_minecraft_api_metadata":""},"mod_category":[97,873,92],"mod_loader":[99],"minecraft_version":[36,94,62,37,73,74,38],"class_list":["post-70054","mod","type-mod","status-publish","has-post-thumbnail","hentry","mod_category-fabric","mod_category-library","mod_category-utility","mod_loader-fabric","minecraft_version-1-20-1","minecraft_version-1-20-4","minecraft_version-1-21","minecraft_version-1-21-1","minecraft_version-1-21-2","minecraft_version-1-21-3","minecraft_version-1-21-4"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>SocketPlugin - Minecraft<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/vpesports.com\/minecraft\/mods\/figurasocketplugin\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SocketPlugin - Minecraft\" \/>\n<meta property=\"og:description\" content=\"A Figura Addon that allows TCP sockets and more.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/vpesports.com\/minecraft\/mods\/figurasocketplugin\/\" \/>\n<meta property=\"og:site_name\" content=\"Minecraft\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/vpesports.com\\\/minecraft\\\/mods\\\/figurasocketplugin\\\/\",\"url\":\"https:\\\/\\\/vpesports.com\\\/minecraft\\\/mods\\\/figurasocketplugin\\\/\",\"name\":\"SocketPlugin - Minecraft\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/vpesports.com\\\/minecraft\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/vpesports.com\\\/minecraft\\\/mods\\\/figurasocketplugin\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/vpesports.com\\\/minecraft\\\/mods\\\/figurasocketplugin\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/vpesports.com\\\/minecraft\\\/wp-content\\\/uploads\\\/2026\\\/06\\\/figurasocketplugin-icon-5bd268151b703b1e12465bc58b0e327e6750bac1.png\",\"datePublished\":\"2026-06-03T23:41:48+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/vpesports.com\\\/minecraft\\\/mods\\\/figurasocketplugin\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/vpesports.com\\\/minecraft\\\/mods\\\/figurasocketplugin\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/vpesports.com\\\/minecraft\\\/mods\\\/figurasocketplugin\\\/#primaryimage\",\"url\":\"https:\\\/\\\/vpesports.com\\\/minecraft\\\/wp-content\\\/uploads\\\/2026\\\/06\\\/figurasocketplugin-icon-5bd268151b703b1e12465bc58b0e327e6750bac1.png\",\"contentUrl\":\"https:\\\/\\\/vpesports.com\\\/minecraft\\\/wp-content\\\/uploads\\\/2026\\\/06\\\/figurasocketplugin-icon-5bd268151b703b1e12465bc58b0e327e6750bac1.png\",\"width\":64,\"height\":64},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/vpesports.com\\\/minecraft\\\/mods\\\/figurasocketplugin\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/vpesports.com\\\/minecraft\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Mods\",\"item\":\"https:\\\/\\\/vpesports.com\\\/minecraft\\\/mods\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"SocketPlugin\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/vpesports.com\\\/minecraft\\\/#website\",\"url\":\"https:\\\/\\\/vpesports.com\\\/minecraft\\\/\",\"name\":\"Minecraft\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/vpesports.com\\\/minecraft\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SocketPlugin - Minecraft","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/vpesports.com\/minecraft\/mods\/figurasocketplugin\/","og_locale":"en_US","og_type":"article","og_title":"SocketPlugin - Minecraft","og_description":"A Figura Addon that allows TCP sockets and more.","og_url":"https:\/\/vpesports.com\/minecraft\/mods\/figurasocketplugin\/","og_site_name":"Minecraft","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/vpesports.com\/minecraft\/mods\/figurasocketplugin\/","url":"https:\/\/vpesports.com\/minecraft\/mods\/figurasocketplugin\/","name":"SocketPlugin - Minecraft","isPartOf":{"@id":"https:\/\/vpesports.com\/minecraft\/#website"},"primaryImageOfPage":{"@id":"https:\/\/vpesports.com\/minecraft\/mods\/figurasocketplugin\/#primaryimage"},"image":{"@id":"https:\/\/vpesports.com\/minecraft\/mods\/figurasocketplugin\/#primaryimage"},"thumbnailUrl":"https:\/\/vpesports.com\/minecraft\/wp-content\/uploads\/2026\/06\/figurasocketplugin-icon-5bd268151b703b1e12465bc58b0e327e6750bac1.png","datePublished":"2026-06-03T23:41:48+00:00","breadcrumb":{"@id":"https:\/\/vpesports.com\/minecraft\/mods\/figurasocketplugin\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/vpesports.com\/minecraft\/mods\/figurasocketplugin\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/vpesports.com\/minecraft\/mods\/figurasocketplugin\/#primaryimage","url":"https:\/\/vpesports.com\/minecraft\/wp-content\/uploads\/2026\/06\/figurasocketplugin-icon-5bd268151b703b1e12465bc58b0e327e6750bac1.png","contentUrl":"https:\/\/vpesports.com\/minecraft\/wp-content\/uploads\/2026\/06\/figurasocketplugin-icon-5bd268151b703b1e12465bc58b0e327e6750bac1.png","width":64,"height":64},{"@type":"BreadcrumbList","@id":"https:\/\/vpesports.com\/minecraft\/mods\/figurasocketplugin\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/vpesports.com\/minecraft\/"},{"@type":"ListItem","position":2,"name":"Mods","item":"https:\/\/vpesports.com\/minecraft\/mods\/"},{"@type":"ListItem","position":3,"name":"SocketPlugin"}]},{"@type":"WebSite","@id":"https:\/\/vpesports.com\/minecraft\/#website","url":"https:\/\/vpesports.com\/minecraft\/","name":"Minecraft","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/vpesports.com\/minecraft\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/vpesports.com\/minecraft\/wp-json\/wp\/v2\/mod\/70054","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vpesports.com\/minecraft\/wp-json\/wp\/v2\/mod"}],"about":[{"href":"https:\/\/vpesports.com\/minecraft\/wp-json\/wp\/v2\/types\/mod"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/vpesports.com\/minecraft\/wp-json\/wp\/v2\/media\/70055"}],"wp:attachment":[{"href":"https:\/\/vpesports.com\/minecraft\/wp-json\/wp\/v2\/media?parent=70054"}],"wp:term":[{"taxonomy":"mod_category","embeddable":true,"href":"https:\/\/vpesports.com\/minecraft\/wp-json\/wp\/v2\/mod_category?post=70054"},{"taxonomy":"mod_loader","embeddable":true,"href":"https:\/\/vpesports.com\/minecraft\/wp-json\/wp\/v2\/mod_loader?post=70054"},{"taxonomy":"minecraft_version","embeddable":true,"href":"https:\/\/vpesports.com\/minecraft\/wp-json\/wp\/v2\/minecraft_version?post=70054"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}