aspose file tools*
The moose likes Java in General and the fly likes TCP\IP communication Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "TCP\IP communication" Watch "TCP\IP communication" New topic
Forums: Java in General Sockets and Internet Protocols
Author

TCP\IP communication

Neeba Rebbaca
Ranch Hand

Joined: Oct 21, 2008
Posts: 159
I want to send data xml to client's TCP\IP port over a web.I don't want to use Applet. Is there any other way to do it?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42611
    
  65
Well, what makes a "client" is that it has connected to a server somehow - how did it do that? Can't you use whatever connection it has made already?


Ping & DNS - my free Android networking tools app
Neeba Rebbaca
Ranch Hand

Joined: Oct 21, 2008
Posts: 159
I need to create a xml and that xml to a tcp\ip port where a printer is connected, this is printer is connected to a network. This XML creation and sending should happen from a web page,which is constructed using .net and the front end scripts are html and js. I want to know whether i can do this xml construction and sending using java.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42611
    
  65
So this printer would be connected to the machine that accesses the web page? Or to some other machine? If the server process that implements this uses .Net, why should the sending of this message happen in Java? Wouldn't it be easier to use .Net as well?
Neeba Rebbaca
Ranch Hand

Joined: Oct 21, 2008
Posts: 159
Its another machine. No the one which access the webpage. all i need to do is just send data a port. i just tried using Socket in java as standalone. can it done using servlet or jsp?

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42611
    
  65
1) What happened when you tried? Be detailed.

2) Is the machine with the printer reachable from the machine that tries to connect to it, and is that port (which one?) open?

3) When is this code called? As I understand it, the web page that triggers it is written in .Net - how does that trigger Java code?

4) ObjectOutputStream is almost certainly the wrong class to use (it definitely is the wrong one if the receiving process is not a Java process - which is highly unlikely for a printer). What kind of data/protocol does the receiving machine expect?
Neeba Rebbaca
Ranch Hand

Joined: Oct 21, 2008
Posts: 159
Thanks for your reply,Ulf Dittmer.

1. I create it as a basic java class and executed from command prompt. it worked. (Printer is a Intermac)

2. Though it works based on .net, the front end are in html and javascript.

3. Code should be called, when a button is clicked on the html.

4. Now, my question is if i convert it to either servlet or jsp, will this works?means, will the data be sent to tcp\ip port(I don't have printer to check it right now)
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42611
    
  65
2. Though it works based on .net, the front end are in html and javascript.

The client side is irrelevant since this code would be executed from the server.

4. Now, my question is if i convert it to either servlet or jsp, will this works?means, will the data be sent to tcp\ip port

Well, if it works from your desktop it might work from the server, provided it has network access to the printer. You would do this from a servlet, not from a JSP. You'd need to rewrite the relevant .Net code/pages into servlets/JSPs, obviously.
Neeba Rebbaca
Ranch Hand

Joined: Oct 21, 2008
Posts: 159
Thanks for your reply. Planning to call from a button by this way , "http://myservlet/PrinterServlet?params="data"

One more question, what happens if the xml file i send is going to a large one ? Will there be any restriction ?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42611
    
  65
Define "large". Printers can normally handle documents hundreds of pages long.
Neeba Rebbaca
Ranch Hand

Joined: Oct 21, 2008
Posts: 159
Large i mean here is, I'm going to post data to tcp\ip port as a form of xml, so my question is can tcp ip can handle a voluminous data? say like 15MB of xml data?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42611
    
  65
15MB is not a particularly large file size these days. I'm sure you have downloaded files much larger than that.
Neeba Rebbaca
Ranch Hand

Joined: Oct 21, 2008
Posts: 159
thanks for your reply.
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 8223
    
  23

Neeba Rebbaca wrote:Its another machine. No the one which access the webpage. all i need to do is just send data a port. i just tried using Socket in java as standalone. can it done using servlet or jsp?

It seems like an odd way to do this: a bit like the network equivalent of cat-ing directly to a printer device, which is never a very good idea.

Couldn't you just use the Java Print Service? I'm no expert on this stuff, but it would seem odd if it doesn't allow you to print to a network printer. Or is there other stuff going on that you haven't told us about?

Winston

Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: TCP\IP communication