LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP write and read

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

0 Kudos
Message 1 of 8
(4,287 Views)

Hi Chun,

it would be easier if you attach your code. Did you see the examples in the example finder? Search for TCP.

 

Mike

0 Kudos
Message 2 of 8
(4,286 Views)

.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. 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 3 of 8
(4,267 Views)

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

0 Kudos
Message 4 of 8
(4,255 Views)

 

 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. 

 

 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 5 of 8
(4,253 Views)

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. 

 

 

Message Edited by pallen on 04-21-2009 10:08 AM
---------------------
Patrick Allen: FunctionalityUnlimited.ca
0 Kudos
Message 6 of 8
(4,241 Views)

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

0 Kudos
Message 7 of 8
(4,212 Views)

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

 
 
The examples DATA CLIENT and DATA SERVER show everything you need to know to make it work. 
They're in the NETWORKING section of the Example Finder.
 
If you still can't get it, post your code as someone requested earlier. 
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 8 of 8
(4,207 Views)