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

Search the Community

Showing results for tags 'internet'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • OpenComputers
    • Announcements
    • Feedback
    • IRC
  • Code Central
    • Support
    • Showcase
    • Tutorials
  • Addons & More
    • Addons Mods
    • Architectures
    • OpenEngineering Task Force
  • General
    • Lounge
    • Forum Games
    • Showcase
    • Servers
  • Archives
    • Public Archives

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Fediverse ID



Found 14 results

  1. Hi ! My project is te get my AE Inventory send to a SQL Database using a JAVA TCP server (because JAVA is the language I'm more familiar with). My issue is when I'm done sending my packet, my java program crash (I give you details below). I've tested with a JAVA TCP client and it work fine. My OC program is very basic. It's just to test my TCP server : local net = require("internet") local con = net.open("my ip",my port) if(con) then con:write("Hi ! I'm your OpenComputer ! \r\n") con:write("Test Sentence 2") con:close end This is my Class wich handle the input informations : import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; import java.net.InetSocketAddress; import java.net.Socket; import java.net.SocketException; public class ClientProcessor implements Runnable{ private Socket sock; private BufferedInputStream reader = null; public ClientProcessor(Socket pSock){ sock = pSock; } public void run(){ System.err.println("Client Inbound"); boolean closeConnexion = false; while(!sock.isClosed()){ try { reader = new BufferedInputStream(sock.getInputStream()); String response = read(); InetSocketAddress remote = (InetSocketAddress)sock.getRemoteSocketAddress(); String debug = ""; debug = "Thread : " + Thread.currentThread().getName() + ". "; debug += "Demande de l'adresse : " + remote.getAddress().getHostAddress() +"."; debug += " Sur le port : " + remote.getPort() + ".\n"; debug += "\t -> Commande reçue : " + response + "\n"; System.err.println("\n" + debug); }catch(SocketException e){ System.err.println("LA CONNEXION A ETE INTERROMPUE ! "); break; } catch (IOException e) { e.printStackTrace(); } } } //Function to read the inbound data private String read() throws IOException{ String response = ""; int stream; byte[] b = new byte[4096]; stream = reader.read(b); response = new String(b, 0, stream); return response; } } So. I start my JAVA server, and then launch my OC test program. Here is the result : Thread : Thread-1. Demande de l'adresse : my ip. Sur le port : 60152. -> Commande reçue : Hi ! I'm your OpenComputer ! Test Sentence 2 Hi ! I'm your OpenComputer ! Test Sentence 2 Exception in thread "Thread-1" java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.String.checkBounds(String.java:381) at java.lang.String.<init>(String.java:545) at server.opencomputer.perso.ClientProcessor.read(ClientProcessor.java:71) at server.opencomputer.perso.ClientProcessor.run(ClientProcessor.java:36) at java.lang.Thread.run(Thread.java:748) I already started digging on the issue. For me, the "String index out of range: -1" is due to an "empty" packet while trying to build the answer in the "response" variable with "response = new String(b, 0, stream);". Since "stream" is equal to -1, it make it crash. But I don't know if it come from OpenComputer or my Java server since with a Java Client it work fine. I've also analyzed the inbound packets and I don't see empty or faulty one. I already have a program for listing my AE inventory, and a Class to input things into a SQL database (Mariadb server is ready too). Only a small thing before it's done Is there something I'm missing ? Thanks for your help The Frenchtopus.
  2. I created a reddit browser for OC. Here is a video: [LINK] It uses my image encoding alghoritm that makes images draw rather fast on OC. (The actual image encoding is done on a remote server, because doing it in game would be too slow.) Source code for both server and client To get it working in game, download libfif.lua and redditViewer.lua onto a OpenOS installation and just run redditViewer.
  3. There was no IRC library for OpenComputers, so I've made one. Here's a demo bot that uses it: local com = require("component") local event = require("event") local thread = require("thread") local gpu = com.gpu local irc = require("irc") local events = irc.events local env = setmetatable({ irc = irc, events = events, }, {__index = _G}) local client = irc.builder() :connection { host = "irc.esper.net:6667", throttling = { maxDelay = 2, maxThroughput = 5, }, } :auth { nickname = "oc-finger-irc", username = "fingercomp", realname = "OpenComputers IRC client library", } :bot { channels = {"#oc-finger-irc"}, tracking = { users = true, modes = true, account = true, userInfo = true, }, } :execution { threaded = true, reconnect = true, catchErrors = true, } :subscribe(events.irc.command, events.priority.high, function(self, client, evt) gpu.setForeground(0x00ff00) print("→ " .. evt.rawLine) gpu.setForeground(0xffffff) end) :subscribe(events.irc.write, events.priority.normal, function(self, client, evt) gpu.setForeground(0x00dbff) print("← " .. evt.line:gsub("[\r\n]*$", "")) gpu.setForeground(0xffffff) end) :subscribe(events.irc.message, irc.events.priority.normal, function(self, client, evt) if evt.source.nickname == "fingercomp" then if evt.message == "::quit" then evt:reply("Quitting.") evt.client:stop(("%s told me to quit."):format(evt.source.nickname)) elseif evt.message == "::spam" then evt:reply("1") evt:reply("2") evt:reply("3") evt:reply("4") evt:reply("5") elseif evt.message == "::longmsg" then local msg = {} for i = 1, 256 do if i == 128 then table.insert(msg, tostring(i) .. " ") else table.insert(msg, tostring(i)) end end evt:reply(table.concat(msg)) elseif evt.message == "::error" then (nil).test() elseif evt.message:sub(1, #"::exec ") == "::exec " then local code = evt.message:sub(#"::exec " + 1) local chunk, reason = load("return " .. code, "=irc", "t", env) if not chunk then chunk, reason = load(code, "=irc", "t", env) end if not chunk then evt:reply(("\x0304Error:\x0f %s"):format(reason)) else local result = table.pack(xpcall(chunk, debug.traceback)) local success = table.remove(result, 1) result.n = result.n - 1 for i = 1, result.n, 1 do if type(result) ~= "string" and type(result) ~= "number" and type(result) ~= "boolean" and type(result) ~= "nil" then result[i] = tostring(result[i]) else result[i] = ("%q"):format(result[i]):gsub("\\\n", "\n") end end if not success then evt:reply(("\x0304Error:\x0f %s"):format(result[1]:match("^[^\n]*"))) io.stderr:write(("%s\r\n"):format(result[1])) elseif result.n > 0 then evt:reply(table.concat(result, " ", i, result.n)) else evt:reply("\x0309Success") end end end end end) :subscribe(events.irc.ctcpRequest, irc.events.priority.normal, function(self, client, evt) if evt.ctcpCommand == "TIME" then evt:reply(os.date("%F %T")) end end) :subscribe(events.client.error, irc.events.priority.top, function(self, client, evt) print("Caught: " .. evt.traceback) evt:cancel() end) :build() local t = thread.create(function() repeat local evt = event.pull("interrupted") until evt end) env.client = client client:run() thread.waitForAny({t, client.thread}) client:stop("Quitting.") os.exit() I don't want to brag about it too much, but I think the code is pretty. Features Threaded execution. A nice API. IRCv3.2 capability negotiation. Throttling to prevent the bot from triggering anti-flood mechanisms. Tracks channel members, modes, nick changes, account names, etc. Automatically reconnects if it's disconnected from the IRC server. Splits long messages over multiple lines. The event bus can use coroutines as message handlers. Links The GitLab repository: https://gitlab.com/cc-ru/irc-oc Documentation: https://gitlab.com/cc-ru/irc-oc/-/wikis/home Demo programs: https://gitlab.com/cc-ru/irc-oc/snippets
  4. Ever needed real-world time in OpenComputers? I did today, so I did something about it. realtime realtime is a set of libraries and protocols designed to let you synchronise your computers with the real world, and includes: The realtime library, for taking and keeping time. The realtime-sync daemon, for synchronising your realtime library with the real world The realtime-relay daemon, for synchronising your realtime across the local network. All of these can be downloaded via oppm, or from the Minitel GitHub repository. Additionally, all of these come with manual pages describing their functionality and usage, all of which can be found here.
  5. In OpenComputers we currently have a simple highly abstracted networking model. We do have ports, thankfully, but besides that the model is highly abstracted and thusly underpowered. The first suggestion, is remove the abstraction on network communication in the first place. Allow this to be configured in the mod preferences file, but have it enabled by default. By default, there is no “hardware addresses”. A cable is just that, a cable. The only API by the mod is “broadcast and receive”. In the OS provided by the game by default could still have the same API as now. The different is it’d behave like broadcast, with packets being what are broadcasted. The new network card API (excluding any OS-level abstraction would look like this: - card:up() - card:down() - card:listen() - card:transmit(raw) Already, we now have a lot of extra things. It encourages crafting an encryption card (or whatever it’s called) because users can now snoop and preform MITM attacks on these packets, since there is no game mechanic (provides by the mod itself) preventing posing as somebody else. That also means you can simulate multiple networks cards in software while crafting only one. Second, something that kinda complements the idea of the first suggestion. Cable bandwidth limits. Just like normal cables, there is a limit to the amount of data we can cram into a single cable. Since the last suggestion removed the magic of hardware addresses, we actually need to listen to packets on the cable. We can only process so many packets so often. Now, us developers have an actual NEED to work on more complex softwares. We need to design things like intelligent multiplexing algorithms and routing softwares to efficiently receive, decode, process, bundle, re-encode, and transmit packets. There will also now be tiered network cards, that change things like the maximum number of packets a second the card can receive and transmit. It could also limit what kinds of cables the system can connect to. For example, you might need a tier four to connect to fibreglass. Keeping on the same note, Radio Frequencies. Just like cables, we can only send so much data through the air at once. One way we allow for more people talking wirelessly, besides just having everybody wait their turn in a long que to talk, is Frequency Multiplexing (FM). This also adds a new unique challenge, but powerful tool, to busy areas. You can allow a lot of people to talk at once using multiple frequencies, but you need to develop systems to send data to users on the right frequency to have them actually receive it. Radio Frequencies would have different reasons to use it. Higher frequencies can transmit farther, but they use more power and they can be affected by things like weather (If I understand correctly some RF wavelengths can experience interference due to the size of the droplets). Lower frequencies would use less energy, but have lower range, but less susceptible to interference from things like weather (however, if memory serves right, lower frequencies are more noisy; translates in-game to possibly more failed packets and corruption). In the game, tiered wireless cards have been added. The higher tiers have the capability for wider bandwidth (meaning the range of RFs the card can use), multiple antennas (allowing use of multiple frequencies at once), and higher bandwidth (packets/second it can receive and transmit). To craft these, one good way could be like how you setup server racks. You can open a GUI where there are slots. You need better processor for higher throughput (packets/second) and higher memory for higher throughout volume capacity. All my suggestion make the game more difficult, sure. That’s why I use it over ComputerCraft. I like having my computers be complex and expensive, they should be! They’re freaking computers. This adds the ability to design a lot of new things, and new challenges. However, they won’t really effect new players. On your small one or Teo computer network running the default OS, everything will work perfectly fine. Only large-scale complex systems have these issues.
  6. It seems completely funny but I am actually trying to get through this for the last 2 days: I try to access weather data through the OpenWeatherMap.org API wich seems to work fine with internet.request(url). The problem is just that it returns me the JSON as a table instead of a String. I tried to access fields of that table but everything seems to return nil. I just can't get to access anything from that table. There are tons of JSON serialization librarys out there but they all need the JSON as a String. I am completely lost rn. This is the API response that gets stored as a table for some reason: {"coord":{"lon":7.68,"lat":52.85},"weather":[{"id":500,"main":"Rain","description":"light rain","icon":"10n"}],"base":"stations","main":{"temp":10.51,"pressure":999,"humidity":66,"temp_min":10,"temp_max":11.11},"visibility":10000,"wind":{"speed":5.1,"deg":230},"rain":{"3h":0.11},"clouds":{"all":92},"dt":1552771115,"sys":{"type":1,"id":1871,"message":0.0045,"country":"DE","sunrise":1552714945,"sunset":1552757625},"id":2810860,"name":"Werlte","cod":200} My Lua code couldn't be simpler: local web = require("internet") local data = web.request(<API_LINK>) -- data is of type table and I don't know how to get any values. Tried so many combinations on indices. -- For each loop works to loop through everything though
  7. This is the project I was working on 2 months ago or so. I couldn't find a real shell client for OC, so I had to create one by myself. That's how NGSH was born. Contributions and pull requests are welcome There are two versions: The first one uses the Python pyte library for terminal emulation, but it is very slow (it redraws everything) and has no colour support. The second one (I called it PTY) takes advantage of OpenOS's VT100 library, which is fast and has colour, but very broken and inaccurate due to missing checks and/or escape sequences. I may get back to serverside emulation at some point, because OC isn't fast enough for VT100 emulation. For instructions see my GitLab repository (make sure to download the PTY version) Before you run the client, make sure to install my improved terminal libraries for proper emulation of \r, \b, and inverse video, like so: pastebin run rs0QiTHp Screenshots:
  8. My first big program. It shows: -a randomized message (requested from my HTTP server, and fortune on the server side), -Computer address, used/free/all RAM, energy levels, uptime, filesystem for booting, whether the computer can do HTTP requests, -List of components available Thanks to CptMercury and payonel for some parts of the code. I will make it available through OPPM soon, but for now you will need to get it through GitHub: https://github.com/AugiteSoul/AugiteOpenComputers/blob/master/systeminfo/systeminfo.lua Feel free to send some feedback, positive or not! I will try to answer everyone.
  9. Is there any way to send PUT and DELETE requests, or any mods that add this functionality?
  10. A simpe API to connect to a Websocket Server / Endpoint Forgot to mention: This API requires a Internet Card and Lua 5.3 Example Code: local ws = require("websocket_client"); local event = require("event"); local cl = ws.create(function(ev ,var1) print(ev .. "->" .. var1) end); cl:connect("localhost", 12345, "/"); while true do local ev = {event.pull()}; if ev[1] == "interrupted" then cl:disconnect(); return; elseif ev[1] == "touch" then cl:send("HI"); end end Full API documentation here: https://github.com/feldim2425/OC-Programs/blob/master/websocket_client/API.md To download and install the API simply run this command: pastebin run xnXssAtH
  11. When using the internet component or internet API I could not find a reliable way to detect a broken socket to an internet adress. Once the connection is broken by the external endpoint, the broken socket can only be detected by writing to the socket, not by reading. This makes writing a good program very difficult as it would be impractical to send a ping every second just to detect if the socket is still alive. Is there any possibility I did not see? Or is none implemented?
  12. So i started messing about with the internet card, i can get onto google just fine as long as i use http with port 80. But when i try to use anything with a https and port 443 i can't get anything. I keep getting an invalid port or url address. Im pretty sure my address is right but i think my port might be wrong
  13. spazz

    Web Browser

    Description: Looking for something that can open webpages on the Tier 3 Screens, took a look around and couldnt find any Function: I have a rather large group of friends who run a LAN server cross country, and as a 'downtime' like thing we were looking at finding a web browser to watch a movie or something on in game Deadline: Not to worried about time Additional Information: Setup can be adjusted to fit the program if need be Thank you in advance!
  14. Congon4tor

    TCP Server

    Had some trouble getting a TCP connection between an OpenComputers program (client) and a java program (server), so I thought I could sare this. Here is the lua program: --VARIABLES local event = require("event") local net = require("internet") local term = require("term") local os = require("os") local running = true local con = net.open("", 6667) --FUNCTIONS function sendString(s) con:write(s) print('Sending ' .. string.sub(s,1,s:len()-1) .. ' to server...') con:flush() end function reciveString() local s = con:read() print('Recived ' .. s .. ' from server...') con:flush() end --MAIN if con then print('Connected to the server!') end while running do local s = term.read() sendString(s) reciveString() os.sleep(0) end And here the java code: import java.io.*; import java.net.*; class TCPServer { public static void main(String argv[]) throws Exception { String clientSentence; String capitalizedSentence; ServerSocket welcomeSocket = new ServerSocket(6667); Socket connectionSocket = welcomeSocket.accept(); while (true) { if (!connectionSocket.isConnected()) { connectionSocket = welcomeSocket.accept(); } else { System.out.println("Connected to client"); BufferedReader inFromClient = new BufferedReader( new InputStreamReader(connectionSocket.getInputStream())); clientSentence = inFromClient.readLine(); System.out.println("Received: " + clientSentence); capitalizedSentence = clientSentence.toUpperCase() + "\n"; DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream()); System.out.println("Sending: " + capitalizedSentence); outToClient.writeBytes(capitalizedSentence); } } } } Also make sure you have TCPEnabled on the config file and if your tcp server is in the same machine as the minecraft serve remove form the ip blacklist your networks ip. Hope this helps someone
  • Create New...

Important Information

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