tags:

views:

1255

answers:

9

Hi Guys,

I have a requirement to send some 100 bytes data over internet .My machine is connected to internet. I can do this with HTTP by sending requests and receiving responses. But my requirement is just to send data not receive response. I am thinking of doing this using UDP Client server program. But to do that I need to host UDP client on internet?

Is there any other way to do that?

any suggestions?

+2  A: 

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

Gamecat
+3  A: 

Anything that happens on the internet requires a client and a server.

One box is in the role of client, the other is in the role of server for your specific transaction.

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

Software MUST be running on both to implement some protocol for exchanging data.

A 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, while rarely blocked by firewalls is a privileged port. Generally, you need a web server (e.g., Apache) or privileges to listen on port 80.

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

S.Lott
A: 

If you want a UDP listener on the internet, it will have to be hosted somewhere.

You can get HTTP hosting much easier, it's everywhere, UDP you may need your own machine or at least a VM.

seanb
+1  A: 

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

I would suggest using TCP to save you some headache.

Also, make sure you're not behind a firewall, else your packets won't make it to their destination as you'd expect.

strager
+3  A: 

Cheap answer to send 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
call me Steve
It will receive the response also...that I dont want
Alien01
I see, however you need to receive some information back to be sure that the inbound information was received. (you can trick to play around by forging IP address or firewall rules, but I guess it wont lead very far)
call me Steve
just ping some black hole somewhere
Draemon
This makes sense ..just ping some unreachable IP address , that way I am able to send data but not receive response...Thanks for easy solution...
Alien01
+2  A: 

In order to send data but not receive a response, you can simply write your program in such a way that it does not listen for a response. This doesn't mean one won't be sent to you, just that you won't get it.

For example, you can make sure you don't call "recv" on the socket. Also, you can use "shutdown" to disable reads on the socket. Depending on the underlying implementation, going the "shutdown" route might cause all incoming packets to simply be dropped.

As far as how to send the packets, really any sort of protocol will work. Of course, you need to know of a destination server on the Internet, but you've got plenty of options. Perhaps the simplest route to take is what you have suggested: HTTP (perhaps use www.google.com as your destination server).

Brian
A: 

Look up sockets.

Paul Nathan
+1  A: 

Hmmm...

You want to send short messages over the internet, but without any response.

Your application wouldn't by any chance be some kind of spyware, would it?

Die in Sente
This is not for spyware .Well I am doing some tests where I need to send data after every 5 min and there should not be any other data other than send data. So if I use Http, TCP I will get back ACK and responses which I dont want.
Alien01
+1  A: 

Use UDP. Open a socket, send the data, close the socket. That's it. Here is a Python version of the client:

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()

On the Wikipedia page about UDP there is some corresponding WinSock code. Of course the other side must be reachable, and there must be someone listening there, otherwise the target machine will reply with an ICMP "port unreachable" packet (at least if it complies with standards).

Federico Ramponi