04-21-2009 04:12 AM
Hi all,
i am working with TCP read and write on a computer.I have 2 programms,one is to write data,one is to read data.The problem is when the port in Read and Write is same, but there is a error in write (ERR 57),which said that the port is in use.because there no data to be written,the time in read elapsted and a error came out(ERR 56).I have tried many times with difeerece portnummber,but no use.
so i'd like to ask if anyone know what it was going on?
i appreciate your answer.(The platform is LabVIEW 6i)
chun
04-21-2009 04:15 AM
Hi Chun,
it would be easier if you attach your code. Did you see the examples in the example finder? Search for TCP.
Mike
04-21-2009 07:33 AM
.The problem is when the port in Read and Write is same,
The TCP READ and TCP WRITE functions do not have a PORT parameter.
I don't know what you mean.
Typically, you CREATE LISTENER on the server side, and listen on the port you want (55555, for example).
On the client side, you OPEN CONNECTION and specify 55555 as the remote port.
Once you have the connection, you read and write on THAT SAME CONNECTION.
It's exactly like a telephone - either end can talk, either end can listen.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
04-21-2009 08:13 AM
Hi,Seve
I have read the example of TCP.The port in WRITE and READ should be the same.Before I have put WRITE and READ in a VI,this proplem came out also,so i used the value i of while loop multiplying a factor as the port nummer, when this nummber didn't be over 65536, this VI worked well,becuse i found the portnummber should change every loop but still in the same of WRITE and REAd. This time i had 2 programms,a server and a client, so i specified a costant nummber like 47799,this problem came out always.I tried other nummbers, but no use.
This is the proplem i got.
chun
04-21-2009 08:22 AM
The port in WRITE and READ should be the same
I still don't know what you mean. The TCP READ and TCP WRITE functions do not have a PORT parameter.
You WRITE to a CONNECTION.
You READ from a CONNECTION.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
04-21-2009 09:07 AM - edited 04-21-2009 09:08 AM
I think you're missing the TCP Open Connection.vi
It's that VI that takes in the IP address and the Port information and passes it along to the Read, Write and other TCP functions. Before you can have a connection to write to or read from, you must first open it.
Use the Example Finder in LabVIEW and search for TCP. It might be easier to modifiy an existing example to do what you need.
Good luck.
04-22-2009 09:16 AM
Hi,
i think i have made a mistake. the TCP write or read is a whole VI,which is a server or client.It is not the single fuction of WRITE or READ.Sorry. In my VI, i have used TCP open connection in read(i.e.client) to open IP and port.In write(server) i created Listener. My problem is, the ports in Listner and in TCP open connection were the same.But when datas transfered, there was always a error(ERR 57) happend which said the port was being used. i changed the portnummber in server and client but no use.So i'd like to ask somebody if he knows this.
chun
04-22-2009 10:03 AM
For one thing, READ and CLIENT don't mean the same thing.
WRITE and SERVER don't mean the same thing.
You can set them up that way if you want, but that's not universal.
The SERVER is the piece that listens for a connection (waits for the phone to ring).
The CLIENT is the one that initiates a connection (dials the phone).
Once the connection is established, either end can read (receive), either end can write (send).
Blog for (mostly LabVIEW) programmers: Tips And Tricks