TCP/IP Send

Aquí puedes preguntar o compartir tus dudas y conocimientos acerca del programa
Hello everyone, i need help regarding sending data into remote host using TCP/IP or UDP
Our teacher created an application that can merely receive data using TCP/IP or UDP, now she want us to create a simple application in any language that we can send data to her application,

example: Her application is running in this IP: 192.168.10.10 Port 6524

so i think using AMS if its possible.

i found example_TCP_SERVER_MULTITHREADED i tried but the connection becomes lost after few minutes.
anyone can provide simple example apz for this? thank you so much.



Sendai
For this job theres already luasocket, googles basic udp client:
local socket = require("socket")
udp = socket.udp()
udp:setpeername("192.168.1.xxx", 5474)
udp:send("Data!")
To test it you can use simplest network tool "nc" from here: https://joncraton.org/blog/46/netcat-for-windows/

Open you server by running <nc.exe -u -l 5474> it will listen for udp datagrams then run your program, you must see the output on console
i Pabloko.. thanks for this.. i will study on this example hope i can get it before the deadline hahaha.. :awesome-1417754492:
-- SERVER
-- load namespace
local socket = require("socket")
-- create a TCP socket and bind it to the local host, at any port
local server = assert(socket.bind("*", 0))
-- find out which port the OS chose for us
local ip, port = server:getsockname()
-- print a message informing what's up
print("Please telnet to localhost on port " .. port)
print("After connecting, you have 10s to enter a line to be echoed")
-- loop forever waiting for clients
while 1 do
  -- wait for a connection from any client
  local client = server:accept()
  -- make sure we don't block waiting for this client's line
  client:settimeout(10)
  -- receive the line
  local line, err = client:receive()
  -- if there was no error, send it back to the client
  if not err then client:send(line .. "\n") end
  -- done with client, close the object
  client:close()
end
-- CLIENT
local host, port = "127.0.0.1", 100
local socket = require("socket")
local tcp = assert(socket.tcp())

tcp:connect(host, port);
--note the newline below
tcp:send("hello world\n");

while true do
    local s, status, partial = tcp:receive()
    print(s or partial)
    if status == "closed" then break end
end
tcp:close()
HIDE: ON
Hidebb Message Hidden Description

----------------------------<< Client: >>
local socket = require("socket")
local host, port = "192.168.100.47", 51515
local tcp = assert(socket.tcp())

tcp:connect(host, port);
tcp:send("hello world\n");

while true do
    local s, status, partial = tcp:receive()
    print(s or partial)
    if status == "closed" then
      break
    end
end

tcp:close()

--------------------------------------<< Server: >>
local socket = require("socket")
local server = assert(socket.bind("*", 51515))
local tcp = assert(socket.tcp())

print(socket._VERSION)
print(tcp)

while 1 do

  local client = server:accept()

  line = client:receive()
  client:send("it works\n")

end

Hello dripo, thank you for this example codes, i already show to her but
my teacher donot want a generic string to send, she wants something like bytes


Head 2 BYTE 0xFF 0xFE
ID 1 BYTE 0x01 for general data
Length 2 BYTE 0x10 0x00 (Length=16)

still in the processes of reading some articles and other furom about it..
The posts people have given you here are a starter place you send the data you want in the format you want.
:pc: . . .