Sending data over the Internet

I have a requirement to send about 100 bytes of data over the internet. My machine is connected to the internet. I can do this with HTTP by sending requests and receiving responses. But my requirement is to just send the data without a response. I think about it using UDP Client server program. But for this I need to host the UDP client on the internet?

Is there any other way to do this?

any suggestions?

0


source to share


9 replies


Cheap answer for sending 100 bytes of data on the internet.



C:\Windows\system32>ping -n 1 -l 100 -4 google.com

Pinging google.com [209.85.171.99] with 100 bytes of data:
Reply from 209.85.171.99: bytes=56 (sent 100) time=174ms TTL=233

Ping statistics for 209.85.171.99:
    Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 174ms, Maximum = 174ms, Average = 174ms

      

+3


source


Everything that happens on the Internet requires a client and a server.

One window is in the client role, the other is in the server role for a specific transaction.

Usually (but not always) your local box is the client and the other is the server.

The software MUST work on both in order to implement some protocol for communication.



The server can listen on TCP or UDP sockets with some restrictions. Some port numbers are privileged. Some port numbers are blocked by firewalls.

Port 80, rarely blocked by firewalls, is a privileged port. Typically you need a web server (like Apache) or listening privileges on port 80.

"Sending 100 Bytes" can be done using many of the available protocols: Echo, Telnet, FTP, HTTP, to name a few.

+4


source


The big advantage of HTTP is that port 80 is very often open. With other protocols, you have to rely on operators to open the port.

+2


source


To send data, but not receive a response, you can simply write your program so that it does not listen for a response. This does not mean that no one will send you, you just will not receive it.

For example, you can make sure you don't call "recv" on a socket. Alternatively, you can use "shutdown" to disable reading on a socket. Depending on the underlying implementation, a "complete" transition may result in the simple removal of all incoming packets.

As for how to send packets, any protocol will actually work. Of course, you need to know about the target server on the internet, but you have many options. Perhaps the easiest way is what you suggested: HTTP (maybe use www.google.com as the destination server).

+2


source


You need a client (you) and a server (the other end). For UDP, you send datagrams over the Internet (using IP). UDP does not provide the security that TCP does, but does not require a response (but such responses are part of their protocols, not yours).

I would suggest using TCP to save you headaches.

Also, make sure you are not behind a firewall, otherwise your packets will not reach their destination as you expected.

+1


source


Hmmm ...

You want to send short messages over the Internet, but no response.

Your app couldn't be some kind of spyware, could it?

+1


source


Use UDP. Open socket, send data, close socket. It. Here is the Python client version:

import socket
data = 100*'x'
address = ('192.168.0.123', 8080)    # Host, port
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)    # UDP   
sock.connect(address)
sock.send(data)
sock.close()

      

The Wikipedia page about UDP has the corresponding WinSock code. Of course, the other side must be available and there must be someone listening on it, otherwise the target machine will respond with an ICMP "port unreachable" packet (at least if it is standards compliant).

+1


source


If you want to listen to UDP on the internet, it must be hosted somewhere.

You can get HTTP hosting much easier, everywhere, UDP, you might need your own machine, or at least a virtual machine.

0


source


curl is a command line tool for transferring data with URL syntax, supporting DICT, FILE, FTP, FTPS, Gopher, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, Telnet and TFTP. curl supports SSL certificates, HTTP POST, HTTP PUT, FTP upload, HTTP forms based upload, proxies, cookies, user and password authentication (Basic, Digest, NTLM, Negotiate, kerberos ...), resume file transfers, proxy tunneling and downloading other useful tricks.

See examples here

0


source







All Articles