GeeCON Prague 2014*
The moose likes Sockets and Internet Protocols 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 » Sockets and Internet Protocols
Bookmark "TCP\IP communication" Watch "TCP\IP communication" New topic
Author

TCP\IP communication

Neeba Rebbaca
Ranch Hand

Joined: Oct 21, 2008
Posts: 159
we are RFID printing label through an xml file. The printer will be connected to the n/w. I will send xml file to the printer through Hyperterminal via tcp\ip port and label will be printer.
Here i need to automate the file formation and sending part. Need to create xml file and send it to tcp\ip port where the printer is listening. Problem over here is, xml is created and sent to tcp\ip port but label is not printer. but if the same file save to some local drive and if sent to hyper terminal label is being printed. I just want to ensure whether the xml is sent to the port and the complete file is send. Please someone help me in resolving this issue. TIA.

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42057
    
  64
For starters, you should never use Readers or Writers with ports - use Streams instead. I also advise to be explicit about the encoding - the printer may expect data in a particular encoding (instead of whatever the platform default encoding on the machine running this code is - which is what you are currently using).


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

Joined: Oct 21, 2008
Posts: 159
I don't think it uses any encoding technic because i can able to send the same xml which is saved to local drive to tcp\ip via hyper terminal and print. Is there any way to check whether it is posted in tcp\ip sucessfully and complete file reaches to the port?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42057
    
  64
Transforming character data to binary data -which is what this code does- always involved an encoding, and the difference between this code and whatever that other app does may well be the use of specific encodings.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18876
    
  40

Neeba Rebbaca wrote:I don't think it uses any encoding technic because i can able to send the same xml which is saved to local drive to tcp\ip via hyper terminal and print. Is there any way to check whether it is posted in tcp\ip sucessfully and complete file reaches to the port?


By "port", I am going to assume you mean that the file is transferred to the other machine. The easiest way is to work it into the protocol. Have you application either communicate the size of the transfer, or have some sort of end-of-file indicator. Or course, for the second case, you will need to confirm that the indicator is not part of the file.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
GeeCON Prague 2014
 
subject: TCP\IP communication