aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes Write on a port Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Write on a port" Watch "Write on a port" New topic
Author

Write on a port

fahad siddiqui
Ranch Hand

Joined: Jun 14, 2006
Posts: 85
I have an application listening on a port.
How do i approach writing a client which writes a string on a port in java?

I am not sure what to look for, a socket approach needs a server to be listening on the port which accepts the connection from the client.
I want my writing to a port to be asynchronous i.e. It doesnt matter if any application is listening or not, i should just be able to write.

Please advise.
fahad siddiqui
Ranch Hand

Joined: Jun 14, 2006
Posts: 85
Also, it should be a guaranteed write to the port. because using UDP, there is no guarantee that the message was written to the port or lost before that.

Any help would be greatly appreciated.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8971
    
    9

Have a look at the Sockets chapter of the Java Tutorial. In Java, Sockets are an abstraction of TCP/IP and Datagrams are UDP.


[How To Ask Questions On JavaRanch]
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Originally posted by fahad siddiqui:

I want my writing to a port to be asynchronous i.e. It doesnt matter if any application is listening or not, i should just be able to write.

I do not think that this is possible without a listening server.


Rahul Bhattacharjee
LinkedIn - Blog
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
I want my writing to a port to be asynchronous i.e. It doesnt matter if any application is listening or not, i should just be able to write.


As noted before, that's not something sockets can do on their own. I've run into that requirement many times and built some kind of "store and forward" solution. For example, if the server is down you might store messages locally until it comes back up, then send them in batch. Or you might use JMS over a messaging product like IBM's WebSphere-MQ with store and forward built into persistent queuing. Of course that still fails if the MQ server is down.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
jQuery in Action, 2nd edition
 
subject: Write on a port