Socket communication via TCP-IP

Hi,
I am new to CF and would like to establish TCP-IP socket
communication with a remote server. How can I exchange XML messages
with a remote server / port via TCP-IP. Do I need to use the event
gateways of does CF offer another way of setting up socket
communication ?
Many thanks in advance !
John

Do I need to use the event gateways of does CF offer another way
of setting up socket communication ?
I would say, yes, use the socket gateway that ships with
Coldfusion. However, it has a functionality I cannot really
understand. If you are a client setting up a socket to connect to
the gateway, the gateway expects your code to have, beforehand, a
value for the variable
originatorID. Yet,
originatorID is a large, unique integer that the gateway
code generates when you connect. That seems to me to be a
chicken-and-egg dilemma.

Similar Messages

  • Need info on Flash to Hardware Communication via TCP/IP

    Need someone to throw light on how to talk to hardware
    devices from flash. For instance a message needs to be sent to
    mobile on click of a button, looks complex but this just an
    example. would like to just the method that one needs to follow to
    achive the requrement.

    Go Straight for RMI. Load file contents into a buffer. Serialize it as an object and pass it from client to servant. You don't have to deal with TCP-IP or sockets plus you can operate at a much higher level.
    Look at an RMI tutorial.

  • I want to do communication via ethernet using TCP/IP

    i want to do communication via ethernet using TCP/IP i did it but code is runing but im not getting any output

    Look on this easy example: http://www.labviewtutorial.eu/viewtopic.php?f=14&t=328
    You will find there two identical VIs (only port numbers are different). One is for PC1 and other for PC2. If you will get prodlems starting VIs, so look on your firewall settings, you have to unlock ports used in these VIs.
    LabVIEW Portal

  • XModem via TCP for Java

    I am sure that many of you experienced developers have read requests in the past concerning implmentation of Ward Christenen's XModem protocol over a TCP socket. If not, well... you are about to...
    This is a major hack... but it is starting to come together... thanks to Fred Potter for his source code to start this project...
    Objective:
    Basically, I want to create a console application which accepts an incoming connection and starts the receive mode for a XModem file transfer. I am using CGTerm (for Commodore retrocomputing) but can test with HyperTerminal as well...
    The user who connects to the server selects SEND and the FILE to send for a XModem file transfer... and the transfer begins...
    The incoming blocks of 128 bytes are written to a file
    After the transfer is over the server disconnects the client terminal.
    Here is what I have so far:
    import java.net.*;
    import java.lang.*;
    import java.io.*;
    // X-Modem Server implementation via TCP/IP socket
    public class XServer {
    public static FileWriter fw;
    public static void main(String[] args) throws IOException {
    // define the file
    try {   
    fw = new FileWriter("filename.txt");
    } catch (Exception e) {
    System.out.println(e);
    System.exit(0);
    int port = Integer.parseInt(args[0]);
    ServerSocket server = new ServerSocket(port);
    System.out.println("X-Server v1.0 - waiting for connection");
    Socket client = server.accept();
    // Handle a connection and exit.
    try {
    InputStream inputStream = client.getInputStream();
    OutputStream outputStream = client.getOutputStream();
    new PrintStream(outputStream).println("Go to send file mode!"); // sent to client
    System.out.println("Ready to receive file via X-Modem...");
    * BEGIN TRANSFER HERE!
    // set the debug flag
    XModem.debug = true;
    * Here we are instantiating a new InputStream that represents the remote
    * file that we are receiving. In this single line we are attempting to
    * start the flow.
    * Behind The Scenes: We're sending a NAK across the serial line repeatedly
    * until we finaly start seeing the data flow. If we don't see the data
    * flow, then we throw an exception.
    System.out.println("Sending NAK to start receive mode...");
    InputStream incomingFile;
    try {
    incomingFile = new XModemRXStream(inputStream, outputStream);
    } catch (IOException e) {
    System.out.println("ERROR! Unable to start file transfer!");
    e.printStackTrace();
    return;
    System.out.println("Starting file transfer...");
    * Here we are reading from the incoming file, byte by byte, and printing out.
    * Behind The Scenes: Internally, the read() method is handling the task of
    * asking for the next data block from the remote computer, processing it (i.e.
    * parsing, running checksums), and then putting it in an internal buffer. Not
    * all calls to read() will request a new data block as each block contains at
    * least 128 bytes of data. Sometimes you will only hit the buffer.
    try {
    for (;;) {
    int c = incomingFile.read();
    if (c==-1)
    break; // End of File
    // print character / byte
    System.out.print(c+",");
    // write to file
    try {       
    //System.out.print(".");
    fw.write(c);
    } catch (Exception e) {
    System.out.println(e);
    System.exit(0);
    } catch (IOException e) {
    System.out.println("error while reading the incoming file.");
    e.printStackTrace();
    return;
    // done
    System.out.println("File sent.");
    new PrintStream(outputStream).println("");
    new PrintStream(outputStream).println("transfer successful!");
    } finally {
    //client.close();
    // save the file
    try {   
    fw.close();
    System.out.println("file saved.");
    } catch (Exception e) {
    System.out.println(e);
    System.exit(0);
    * XModem keeps track of settings that the Receive and Transmit Stream classes will
    * reference.
    * <p>Copyright: Copyright (c) 2004</p>
    * @author Fred Potter
    * @version 0.1
    class XModem {
    public static boolean debug = false;
    * XModemRXStream is an easy to use class for receiving files via the XModem protocol.
    * @author Fred Potter
    * @version 0.1
    class XModemRXStream
    extends InputStream {
    // CONSTANTS
    private static final int SOH = 0x01;
    private static final int EOT = 0x04;
    private static final int ACK = 0x06;
    private static final int NAK = 0x15;
    private static final int CAN = 0x18;
    private static final int CR = 0x0d;
    private static final int LF = 0x0a;
    private static final int EOF = 0x1a;
    // block size - DON'T CHANGE - I toyed with the idea of adding 1K support but the code is NOT there yet.
    private static final int bs = 128;
    // PRIVATE STUFF
    private int ebn; // expected incoming block #
    private byte[] data; // our data buffer
    private int dataPos; // our position with the data buffer
    private InputStream in;
    private OutputStream out;
    * Creates a new InputStream allowing you to read the incoming file. All of the XModem
    * protocol functions are handled transparently.
    * As soon as this class is instantiated, it will attempt to iniatate the transfer
    * with the remote computer - if unsuccessful, an IOException will be thrown. If it
    * is successful, reading may commense.
    * NOTE: It is important not to wait too long in between calls to read() - the remote
    * computer will resend a data block if too much time has passed or even just give up
    * on the transfer altogether.
    * @param in InputStream from Serial Line
    * @param out OutputStream from Serial Line
    public XModemRXStream(InputStream in, OutputStream out) throws
    IOException {
    this.in = in;
    this.out = out;
    // Initiate the receive sequence - basically, we send a NAK until the data
    // starts flowing.
    init:for (int t = 0; t < 10; t++) {
    if (XModem.debug) {
    System.out.println("Waiting for response [ try #" + t + " ]");
    long mark = System.currentTimeMillis();
    out.write(NAK);
    // Frequently check to see if the data is flowing, give up after a couple seconds.
    for (; ; ) {
    if (in.available() > 0) {
    break init;
    try {
    Thread.sleep(10);
    catch (Exception e) {}
    if (System.currentTimeMillis() - mark > 2000) {
    break;
    // We have either successfully negotiated the transfer, OR, it was
    // a failure and timed out. Check in.available() to see if we have incoming
    // bytes and that will be our sign.
    if (in.available() == 0) {
    throw new IOException();
    // Initialize some stuff
    ebn = 1; // the first block we see should be #1
    data = new byte[bs];
    dataPos = bs;
    * Reads the next block of data from the remote computer. Most of the real XModem protocol
    * is encapsulated within this method.
    * @throws IOException
    private synchronized void getNextBlock() throws IOException {
    if (XModem.debug) {
    //System.out.println("Getting block #" + ebn);
    // Read block into buffer. There is a 1 sec timeout for each character,
    // otherwise we NAK and start over.
    byte[] buffer;
    recv:for (; ; ) {
    buffer = new byte[bs + 4];
    for (int t = 0; t < 10; t++) {
    System.out.println("\nReceiving block [ #" + ebn + " ]");
    // Read in block
    buffer = new byte[buffer.length];
    for (int i = 0; i < buffer.length; i++) {
    int b = readTimed(1);
    // if EOT - don't worry about the rest of the block.
    if ( (i == 0) && (b == EOT)) {
    buffer[0] = (byte) (b & 0xff);
    break;
    // if CAN - the other side has cancelled the transfer
    if (b == CAN) {
    throw new IOException("cancelled");
    if (b < 0) {
    if (XModem.debug) {
    System.out.println("Time out... NAK'ing");
    out.write(NAK);
    continue recv;
    else {
    buffer[i] = (byte) (b & 0xFF);
    break;
    int type = buffer[0] & 0xff; // either SOH or EOT
    if (type == EOT) {
    if (XModem.debug) {
    System.out.println("EOT!");
    out.write(ACK);
    break;
    int bn = buffer[1] & 0xff; // block number
    int bnc = buffer[2] & 0xff; // one's complement to block #
    if (
    (bn != ebn) && (bn != (ebn - 1)) ||
    (bn + bnc != 255)) {
    if (XModem.debug) {
    System.out.println("NAK'ing type = " + type + " bn = " + bn +
    " ebn = " +
    ebn + " bnc = " + bnc);
    out.write(NAK);
    continue recv;
    byte chksum = buffer[ (buffer.length - 1)];
    byte echksum = 0;
    for (int i = 3; i < (buffer.length - 1); i++) {
    echksum = (byte) ( ( (echksum & 0xff) + (buffer[i] & 0xff)) & 0xff);
    if (chksum != echksum) {
    out.write(NAK);
    continue recv;
    out.write(ACK);
    if (ebn == 255) {
    ebn = 0;
    else {
    ebn++;
    break;
    // We got our block, now save it in our data buffer.
    data = new byte[bs];
    for (int i = 3; i < (buffer.length - 1); i++) {
    data[(i - 3)] = buffer;
    dataPos = 0;
    public synchronized int read() throws IOException {
    // If at the end of our buffer, refill it.
    if (dataPos == bs) {
    try {
    getNextBlock();
    catch (IOException e) {
    throw new IOException();
    // If we're still at end of buffer, say so.
    if ( dataPos == bs) {
    return -1;
    int d = data[dataPos];
    if (d == EOF)
    return -1;
    dataPos++;
    return d;
    * A wrapper around the native read() call that provides the ability
    * to timeout if no data is available within the specified timeout value.
    * @param timeout timeout value in seconds
    * @throws IOException
    * @return int an integer representing the byte value read.
    private int readTimed(int timeout) throws IOException {
    long start = System.currentTimeMillis();
    for (; ; ) {
    if (in.available() > 0) {
    return (in.read());
    try {
    Thread.sleep(10);
    catch (InterruptedException ex) {
    //if (System.currentTimeMillis() - start > timeout * 1000) {
    if (System.currentTimeMillis() - start > timeout * 5000) {
    return -1;
    Here was the output...
    Original file:
    (Commodore CBM SEQ file exported to PC using DirMaster)
    ��
    � �
    � ��� �� �� ��� ��
    � �� �� ���� �� ��� ��
    � ��� ����������������������������������������������
    �� ����� ������� ����� �� ����� ������ ����� ���
    � �� ������ ������ ��� ��� �� ��� ���� �� ������
    � � ���
    ����
    � � ��OWERED BY �OLOR 64 ��� V8
    �UNNING �ETWORK64 V1.26A

    �UPPORTING 38400 �AUD �ATES
    �����/����/�������

    �ESTING �CHO-�ET V1 BETA

    �EATURING �ESSAGES, �ILES,
    �ET�AIL, AND �NLINE �AMES!
    �YS�P: � � � � � � � � �

    �RESS ANY KEY TO LOGIN\C�
    The result when the file was uploaded and received by my XServer:
    ? ? ??OWERED BY ?OLOR 64 ??? V8
    ?UNNING ?ETWORK64 V1.26A
    ?UPPORTING 38400 ?AUD ?ATES
    ?ESTING ?CHO-?ET V1 BETA
    ?EATURING ?ESSAGES, ?ILES,
    ?ET?AIL, AND ?NLINE ?AMES!
    ?YS?P: ? ? ? ? ? ? ? ? ?
    ?RESS ANY KEY TO LOGIN\C?
    The result is different!
    Can someone help me along here... I have been trying to figure out how to do this for approx. a year or so... it has been a very slow process.
    I could use a guru to help me out so I can write the upload and download routines for my Commodore BBS PETSCII Emulation Server.
    Visit http://www.retrogradebbs.com for details.
    Thanks.
    Please help out a dedicated developer who is in over his head...
    -Dave

    Ok. Fair enough. What about general information about Xmodem. This is a hard project because of how obscure the legacy technology is that I am having to implement using Java and MySQL.
    I have two major issues which I have to figure out how to troubleshoot and debug, if possible.
    1. The 23+ blocks exception when a file is being received
    2. The exception which is thrown immediately if I try to receive a binary file instead of an ASCII file.
    I read that telnet is a 7-bit technology and that is why Xmodem, which is an 8-bit technology is not that popular as a viable protocol via telnet, whereas Kermit is, since it was developed for 7-bit systems, i.e. mainframes and minicomputers.
    Is this correct?
    If that is the case, why does www.serio.com have a viable X-Y-ZModem library available (for several hundred $$$ of course) which can be used with both RS-232 serial ports and TCP socket ports? Obviously, it can be done. They are the ONLY company with this library for sale for Java to do this. I cannot justify that $$$ amount for a mere hobby (writing the BBS emulation server for supporting Commodore PETSCII (CG) callers via CGTerm or a native C-64 terminal program using Jim Brain's TCPSER middleware, which emulates a Hayes modem via telnet for telBBSing/retrocomputing.
    I really want to learn how to implement a file transfer protocol, since back in the 80s, I used Xmodem, Punter, Y/Z Modem, etc., a lot to upload and download files via modem at baud rates of 2400, 14.4, 19.2, and 38.4, respectively.
    It's fun to learn how the old skool gurus of telecommunications technology did it. It is one thing to run a BBS which supports these technologies and features, and it is an entirely other thing to learn how to design and develop them yourself for implementation into a project such as I taken on.
    It CAN be done. It WILL be done. However, I have just started my exhaustive research on how it needs to be done. I have read up as much as I could on XModem by Ward C., the father of the protocol.
    But, I have no information to help me figure out why the communications are acting as they do so far.
    Can someone please download the xserver.zip file on my website at:
    www.retrogradebbs.com/projects/xserver.zip
    Compile it. Run it. Connect using HyperTerminal, Netrunner, or another telnet terminal emulation program which supports Xmodem file transfers using WinSock.
    See what happens. With finals due in the next two days, this project will have to be put on hold until after I submit my two final projects.
    If anyone knows what needs to be done to support both ASCII and BINARY file transfers via Xmodem via a socket instead of a modem with RTS/CTS hardware flow control, please respond.
    I know for a fact that this can be done.
    - Dave

  • Socket communication failure between Java applet and C++ application

    I have a java applet that connects to a C++ application via Java's ServerSocket and Socket objects. THe C++ application is using the Winsock 2 API. The applet and application are running on an NT workstation (SP 6) and using IE (5.5) For a very simple C++ test applications the communictions work fine. Once more code gets added to the C++ application the portion of the socket that C++ listens to seems to close. Upon performing a recv call the return value is a zero. Microsoft insists this is a sign the Java side has shut down the socket. The Java applet can still receive messages from the C++ app but C++ cannot receive responses from the Java side. Java throws no exceptions and an explicit check of the socket shows no errors. Again, what puzzles me is that it works for simple C++ applications. Are there any known conflicts between Java and C++ in this regard?
    I have inlcuded the basic java code segments below.
    / run Method.
      * This method is called by the Thread.start() method. This
      * method is required for the implementation of the Runnable interface
      * This method sets up the server side socket communication and
      * contiuously loops looking for requests from a external
      * socket.
      * @author Chris Duke
      public void run(){
         // create socket connections
         boolean success = false;
         try {
             cServerSocket = new ServerSocket(cPortID);
             System.out.println("Waiting for client to connect...");
             cClientSocket = cServerSocket.accept();
             System.out.println("Client connected");
             // Create a stream to read from the client
             cInStream = new BufferedReader(new InputStreamReader(
               cClientSocket.getInputStream()));
             // Create a stream to write to the client       
             cOutStream = new PrintWriter(
               cClientSocket.getOutputStream(), true);
             success = true;
         }catch (IOException e) {
             System.out.println("CommSocket:Run - Socket Exception(1) " + e);
             success = false;
         // if the socket was successfully created, keep the thread running
         while (success){
             try{
                // check socket to see if it is still available for reading
                if (cInStream != null && cInStream.ready()){
                    // check for an incoming message
                    String message = ReceiveMessage();
                    // Send message to listeners
                    Event(message);
                if (cInStream == null){
                    success = false;
                    System.out.println("CommSocket:Run - shutdown");
             }catch (IOException e){
                System.out.println("CommSocket:Run - Socket not ready exception");
                break;
    // SendMessage method -
      *  Sends a text message to a connected listener through port specified by portID
      * @author Chris Duke
      * @param  String message - This will be the message sent out through the server
      * socket's port specified by portID.
       public void SendMessage(String message){
          cOutStream.println(message);
          if (cOutStream.checkError() == true)
            System.out.println("SendMessage : Flush = Error");
          else{
            System.out.println("SendMessage : Flush - No Error");
       }

    a very simple C++ test applications the communictions work fine. Once more code gets added to the C++ application the portion of the socket that C++ listens to seems to close.
    This quite strongly implicates the extra code in the C++ App. The firstly thing I would try would be telnet. Try connecting to both versions of the C++ Application and manually reproducing a proper exchange.
    a recv call the return value is a zero. Microsoft insists this is a sign the Java side has shut down the socket.
    A correct implementation of recv should return the number of bytes received, or -1 for an error. A zero return indicates no bytes received not a socket closed/error. This sounds like FUD to me.
    Are there any known conflicts between Java and C++ in this regard?
    I can see no obvious faults, though the code is incomplete, I don't think it's an sockets implementation issue, at either end, it sounds more likely to be a protocol/handshaking bug in the C++ App.

  • Socket communication very slow on Mac OS X 10.6

    Hi everybody,
    I'm using a socket based communication in an application and in Mac OS 10.5 everything works quick and flawless using XCode 3.1.4.
    In Mac OS 10. 6, using XCode 3.2.4, I set the Mac OS X 10.6 SDK, I recompiled the app. but the responsiveness of the app is terrible slow. The GUI itself runs OK but any socket related action is painfully slow (sometimes connection timeout).
    The socket communication is implemented using standard CFSocket classes.
    Is this a XCode migration issue from 3.1 to 3.2 or a Mac OS 10.6 related one (I've seen lots of complains on networking issues)?
    Thank you very much,
    Dan

    Thank you very much for the info but why it worked (and really fast) on 10.5. I also wonder why I didn't run into TCP_NODELAY problem there ? My TCP buffer size is 1K and I'm using the same testing environment.
    Of course there is much more to it than some init parameters but still, what could be so different on 10.6 ? And I tried already the sysctl.conf TCP_NODELAY setting but no effect.
    This is the code (briefly):
    1. CONNECT
    // Create signature from ip and port
    struct sockaddr_in sin; /* TCP/UDP socket address structure. */
    self->m_RemoteSocketSignature = (CFSocketSignature*)malloc(sizeof(CFSocketSignature));
    self->m_RemoteSocketSignature->protocolFamily = PF_INET; /* IPv4 */
    self->m_RemoteSocketSignature->socketType = SOCK_STREAM; /* Stream oriented. */
    self->m_RemoteSocketSignature->protocol = IPPROTO_TCP; /* TCP */
    memset( &sin, 0, sizeof( sin ) );
    sin.sin_len= sizeof( sin );
    sin.sin_family = AF_INET; /* Address is IPv4. Use PF_xxx for protocol
    description, AF_xxx for address description. */
    /* sin.port and sin.addr are in network( big endian ) byte order. */
    sin.sin_port = CFSwapInt16HostToBig( port );
    inet_aton( [address UTF8String], &sin.sin_addr ); /* inet_aton() gives back
    network order addresses from strings. */
    self->m_RemoteSocketSignature->address = CFDataCreate( NULL, (UInt8 *)&sin, sizeof( sin ) );
    // Connect the Write & the Read streams to the socket
    CFStreamCreatePairWithPeerSocketSignature (
    kCFAllocatorDefault,
    m_RemoteSocketSignature,
    & m_ReadStream,
    & m_WriteStream
    if((m_ReadStream != NULL) && (m_WriteStream != NULL))
    bOpenWrite = CFWriteStreamOpen (m_WriteStream);
    bOpenRead = CFReadStreamOpen (m_ReadStream);
    2. RECEIVE
    CFIndex iTotalBytesRead = 0;
    while (true == CFReadStreamHasBytesAvailable(m_ReadStream))
    char buffer[1024];
    CFIndex bufferLength = 1024;
    CFIndex iBytesRead = CFReadStreamRead (
    m_ReadStream,
    buffer,
    bufferLength
    // Error ?
    if(iBytesRead < 0)
    return iBytesRead;
    // EOS ?
    if(iBytesRead == 0)
    return iTotalBytesRead;
    iTotalBytesRead += iBytesRead;
    if(string != nil)
    [string appendString:[NSString stringWithCString:buffer length:(unsigned)iBytesRead]];
    3. SEND
    CFIndex iBytesSent = CFWriteStreamWrite (
    m_WriteStream,
    buffer,
    bufferLength
    Thanks a lot for your help,
    Dan

  • Java WD and Socket Communication

    Hi,
    Is it possible to use Java Socket Communication with Java Web Dynpro. Or if not what is the best approach to have a Java Socket program integrated with a Web Dynpro Communication.
    Basically, I have an application which provides API for communication via Java Sockets.And this needs to be integrated in our SAP application.
    Thanks,
    CD

    Hi,
    You are currently using JCO to "Connect to a Remote System" - JCO will connect to a back-end with the main purpose of "executing BAPI's" in it.
    When you move to WebDynpro, you have what SAP calls Adaptive RFC Model - this will create a "Model Entity" in you WD Project that will do the same thing your JCO does.
    Assume your JCO now calls "BAPI_GET_FLIGHTS", to return the Flights that are currently available - In your newly create WDP Project, you will manually specify what back-end you wanna use when "Importing" and you will tell also the BAPI name. WDP will generate the class structure that you need in order to execute that function.
    JCO is what SAP created to execute BAPI's. JCO can be used by any "Java" like application that needs to connect to the back-end. But when you move to WDP, you don't need to use this anymore - You will use WDP Models.
    Youi will still need your JCO Destinations created in the Application Server, so behind the scenes WDP creates a "layer" so you don't need to code the JCO calls manually.
    Regards,
    Daniel

  • Does XI support Socket communication?

    Hi,
    This question came from our customers and consultants.
    I saw the definition of socket in Wikipedia that it is somehow based on TCP, UDP. So far as I know, XI does not "support" TCP/IP. Does this mean XI does not support Socket either? Or this could be covered in the adapters of XI?
    If XI does not support this, do you have any experience of a solution to socket communication?
    Thanks in advance!
    best regards
    Jing

    Hi,
    sorry for the late reply.
    I understand you that PI does not quite meet healthcare specific requirements.
    Regrading medical equipment with PI, I am not familiar with that part.
    But I have good news regarding HL7 protocol with PI. In the meantime we (SAP) have a service solution of HL7 adapter for PI, that supports HL7 communications based on HL7 message format/protocol.
    Details please see this blog from Vijendra: http://scn.sap.com/docs/DOC-3891
    hope this helps you.
    Regards
    Jing

  • Teststand best practices architecture for communicating with TCP instruments

    Hi,
    I am using Teststand 2014 and LabVIEW 2013 SP1 as the module adapter.
    My Teststand sequence file includes communication with 3-5 different instruments via TCP/IP.
    Such as Spectrum analyzer, generator and other RF measurement devices.
    There are many steps located in subsequences that implement code to communicated with these devices whether to fetch , query or write.
    What is the best architecture to implement this program ?
    As I can see it there are many possibilities, such as :
    1. Launching a subsequence as a new thread in the Sequence Setup. This subsequence calls a VI that dynamically register for events/queue that can be launched from any step. (in this case there is a VI running in the background that can perform Write/Read/Qurey to the instrument and he is triggered from any step using an event or dequeue element)
    This option can be duplicated for any instrument or only once for all of the instrument with prioritizing the event queue.
    2. Creating a communication reference in the Setup of the Main Sequence. And passing it to any step that need it. (there is also the question how to pass this reference… in Teststand globals or in LabVIEW queue).    
    another 2 small questions that I encountered -
    Is using LabVIEW queues and notifiers in TS steps and obtaining their reference (in the LabVIEW code) by name is considered best practices ?
    If I would like to run only one VI in a new thread, should I use a new subsequnce and set it as a new thread or use the Run VI Asynchronously ? what are the differences ?

    I use Action Engines to hold my VISA Sessions and just write my LabVIEW VIs to use those to send commands and read data.  Any returned data can be analyzed in the VI or passed on to TestStand as a step result.  You just need a sequence to run at start up to initialize your Action Engines and another one to close them.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Trying to set up communications via an ethernet with no "Server"

    I am trying to set up communication between my labview software and another pc running something else. we are looking for a solution that allows the other pc to send me data in the form of ascii text ( a tag name followed by a value i.e. "NextProduct: 1002" ) via ethernet cable. It appears that this might be possible via tcp/ip, however I'm not sure how to set it up because my software also has to be able to send the other pc ascii values the same way which makes me think that it wouldnt be basic client/server communications. Any help / advice would be great.

    Hi Dave,
    A simple solution is to use VISA. You only need four functions VISA Open, VISA Read, VISA Write and VISA Close. The name of the resource is builded in the following sysntax: TCPIP[board]::host address:ort:OCKET. It seems that you must know the IP address of your device and the device should not use DHCP services to get a new IP address when it starts.
    TCP/IP uses a caller/listener or client/server mechanism to establish a connection. I have not found how VISA will act and the colleque who tested TCP/IP with VISA is out of office.
    We tested using TCP/IP because one of my customers planned to change his device to use TCP/IP instead of serial communication. We found that we only have to change the resource string and use the "VISA Open" i
    nstead of "VISA Configure Serial Port". And you have also a termination character property you can do it the same way as with serial communication.
    Waldemar
    Waldemar
    Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
    Don't forget to give Kudos to good answers and/or questions

  • X.400 communication via saprouter

    Dear Guru's,
    I have searched on sapnet and the internet for X.400 communication via the saprouter, however I cannot find specific information about this.
    Our XI/PI  establishes X.400 communication, which should be routed via the saprouter through the DMZ. I'm wondering if saprouter can perform this......
    Does anyone worked with this before?
    Kind regards,
    Mark

    Hello,
    SAP router does support TCP/IP, telnet and LPD apart from its native SAP Protocol.
    Please find the below link detailing functions and characteristics of SAP Router:
    http://help.sap.com/saphelp_nw04/helpdata/en/96/c120f8860d11d2ac790000e83539c3/frameset.htm
    The usual way to connect a system to external systems is to put the saprouter alongwith a firewall and put an external server in the DMZ which communicates with SAP via SAP Router using SAP Protocol.
    Typically you can find some configs in ITS and Portals.
    Please check the following link:
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/10dffcbb-9416-2a10-a795-ae2302583d45
    Regards,
    Siddhesh

  • Problem with socket communications

    I am trying to put together a client server socket communication pair.
    I have one application that runs in the background acting as a server and another that can be started and stopped that acts as a client.
    I can start the server and create a server socket with no problem.
    I can start the client and it connects to the server.
    The server acknowledges the connection and appears to go into a blocking state waiting for the client to send another message.
    The server blocks at the line
    parent.logit("Waiting for message from EVR..... ");
    The problem is that when the client sends another message, the server doesn't hear it.
    I am not sure if the problem is with the client or server communication code.
    If anyone out there is a socket communication guru, I would appreciate it if you could tell me what I am doing wrong.
    Thanks
    Server code:
    import java.io.*;
    import java.net.*;
    public class EVRServer
        extends Thread
      EVRDataLoader parent = null;
      ServerSocket serverSock = null;
      Socket clientSock = null;
      BufferedReader reader = null;
      BufferedWriter writer = null;
      int evrPort = 0;
      int retryLimit = 10;
      int retryCount = 0;
      boolean alive = false;
      boolean killSocket = false;
      boolean evrConnected = false;
      boolean retry = true;
      EVRListener evrListener = null;
    //=============================================================================
    // Full constructor
    //=============================================================================
       * Full constructor.
       * @param dl DataLoader - Parent application
       * @param port int Socket port
      public EVRServer(EVRDataLoader dl, int port)
        parent = dl;
        evrPort = port;
    //=============================================================================
    //  Run method - Main thread executed by start() method
    //=============================================================================
       * Main thread executed by start() method
      public void run()
        while (retry)
          if (retryCount > retryLimit)
            retry = false;
          parent.logit("Retry count = " + retryCount);
          // Create new server socket connection
          if (serverSock == null)
            try
              serverSock = new ServerSocket(evrPort);
              parent.logit("Created Server Socket for EVR on port " + evrPort);
              alive = true;
              killSocket = false;
              evrConnected = false;
            catch (Exception e)
              parent.logit(
                  "ERROR - Could not create Server socket connection for EVR: " +
                  e.toString());
              killSocket = true;
              alive = false;
          // Create new client socket connection
          if (clientSock == null)
            try
              parent.logit("Waiting for EVR to connect");
              clientSock = null;
              clientSock = serverSock.accept();
              retryCount = 0;
              evrConnected = true;
              killSocket = false;
              parent.logit("EVR connected on server Socket Port " + evrPort);
            catch (Exception e)
              parent.logit("ERROR - Error accepting EVR connection: " + e.toString());
              killSocket = true;
            try
              reader = new BufferedReader(new InputStreamReader(
                  clientSock.getInputStream()));
              writer = new BufferedWriter(new OutputStreamWriter(
                  clientSock.getOutputStream()));
              parent.logit( "Created reader "+reader);
              parent.logit( "Created writer "+writer);
            catch (Exception e)
              parent.logit(
                  "ERROR - creating reader or writer to EVR: " + e.toString());
              killSocket = true;
          int nullCount = 0;
          while (killSocket == false)
            try
              parent.logit("Waiting for message from EVR..... ");
    //          sendMessage("Data Controller connected on port " + evrPort);
              String s = reader.readLine();
              parent.logit("EVR - Received message: " + s);
              if (s != null)
                parent.processEvrMessage( s);
              else
                sleep(1000);
                nullCount++;
                if (nullCount > 10)
                  parent.logit("Exceeded retry limit: ");
                  killSocket = true;
            catch (Exception ex)
              parent.logit("Error Reading from EVR: " + ex.toString());
              killSocket = true;
          parent.logit( "After while loop");
          evrConnected = false;
          try
            retryCount++;
            parent.logit("Closing EVR connection. ");
            reader.close();
            writer.close();
            clientSock.close();
            writer = null;
            reader = null;
            clientSock = null;
            try
              sleep(1000);
            catch (Exception ee)
              parent.logit("Error after sleep " + ee.toString());
          catch (Exception e)
            parent.logit("Error closing EVR server socket");
    //=============================================================================
    // Call this method to kill the client socket connection.
    //=============================================================================
       * Call this method to kill the client socket connection.
      public void killConnection()
        killSocket = true;
    //=============================================================================
    // Return RTM connected state
    //=============================================================================
       * Return RTM connected state
       * @return boolean - Returns true if RTM is connected to server, false if not.
      public boolean isRtmConnected()
        return evrConnected;
    //=============================================================================
    // Returns state of server socket.
    //=============================================================================
       * Returns state of server socket.
       * @return boolean - Returns true if server socket is enabled, false if not.
      public boolean isServerSocketAlive()
        return alive;
    //=============================================================================
    // Send a message to the client socket.
    //=============================================================================
         * Send a message to the client socket.
         * @param msg String - Message to send.
         * @return boolean - Returns true if message sent OK, false if not.
      public boolean sendMessage(String msg)
        parent.logit(" In EVR Server - Send Message - got message: " + msg);
        if (evrConnected)
          try
            parent.logit("Sending message to EVR: " + msg);
            writer.write(msg + "\n");
            writer.flush();
            return true;
          catch (Exception e)
            parent.logit("ERROR - Error sending message to EVR: " + e.toString());
            return false;
        else
          parent.logit("EVR not connected, cannot send message: " + msg);
          return false;
    }Client code:
    package evrsimulator;
    import java.net.*;
    import java.io.*;
    class PortConnector
          extends Thread
       ServerSocket serverSock = null;
       boolean isIP = false;
       InetAddress addr = null;
       Frame1 parent = null;
       byte[] rawIP;
        //   String initialMsg = "";
       public PortConnector( Frame1 f )
         parent = f;
       // This method is called when the thread runs
       public void run()
          if ( parent.hostName.indexOf( "." ) > 0 )
             isIP = true;
             byte[] rawIP = parent.getRawIP( parent.hostName );
          try
             System.out.println( "Connecting to host " +
                                            parent.hostName + " on port " +
                                            parent.socketPort );
             if ( isIP )
                addr = InetAddress.getByAddress( rawIP );
             else
                addr = InetAddress.getByName( parent.hostName );
             System.out.println( "Inet address = " + addr );
             SocketAddress sockaddr =
                   new InetSocketAddress( addr, parent.socketPort );
             // Create an unbound socket
             parent.client = new Socket();
             // This method will block no more than timeoutMs.
             // If the timeout occurs, SocketTimeoutException is thrown.
             parent.client.connect( sockaddr, parent.socketTimeOut );
             parent.socketOut =
                   new BufferedWriter( new OutputStreamWriter(
                   parent.client.getOutputStream() ) );
             parent.socketIn = new BufferedReader( new InputStreamReader(
                   parent.client.getInputStream() ) );
             parent.localName = parent.localName +
                   parent.client;
             System.out.println( "Parent socketOut = "+parent.socketOut);
             System.out.println( "Parent socketIn = "+parent.socketIn);
          catch ( UnknownHostException uhe )
             System.out.println( "Unknown Host - " + uhe.getMessage() );
          catch ( SocketTimeoutException ste )
             System.out.println( "Socket time out - " + ste.getMessage());
          catch ( IOException ioe )
             System.out.println( "IO exception - " + ioe.getMessage() );
          // Listen on socket for message from host - thread should block.
          parent.portConnected = true;
          while ( parent.portConnected )
             try
                String msg = parent.socketIn.readLine();
                System.out.println( "Message from Host: " + msg );
                System.out.println( "Message from Host: |" + msg + "|" );
                if( msg.length() > 2)parent.processMessage( msg );
             catch ( IOException ioe )
                System.out.println( "Exception creating server socket." );
          try
             System.out.println(
                   "PortConnection - Closing socket and IO connections" );
             parent.socketIn.close();
             parent.socketOut.close();
             parent.client.close();
             parent.clockRunning = false;
             if( parent.heartBeating) heartBeat.interrupt();
          catch ( IOException ioex )
             System.out.println( "Exception closing socket." );
    }

    Your first problem is that you keep closing and recreating the ServerSocket. Do this once only in the lifetime of the server.
    This is such a basic error that I haven't read the rest of the code. Before you go any further I suggest you read the Custom Networking trail of the Java Tutorial.

  • How do I transfer a sound file via TCP?

    I have a .wav file that I'm trying transfer via TCP.  Using LV 8.5, I modified the "Sound File to Output.vi" example to send the data across a TCP connection to a client vi.  But, I've encountered numerous errors along the way with trying to convert the sound data which is a  1-D array of waveform double.  I've attached my server and client VI, but essentially, what I tried to do is break down the array into the y and dt components, send those over the TCP connection, rebuild the waveform client-side, and then play the waveform.  Is there something I'm missing?  Do I need the timestamp information as well and send that over too?  Please let me know how this can be accomplished.  Thanks!
    Attachments:
    Streaming Music - Server.vi ‏97 KB
    Streaming Music - Client.vi ‏65 KB

    One thing to clarify: While the Sound Output Write does not need the dt information, the dt information wouold be required when you use the Configure VI in order to set up the rate.  However, you only need to send that parameter once. Thus, it would seem to me that you want to change your client code so that it checks to see if it receives a special command or something to indicate the start of a new song that may have been sampled at a different rate. If this is the case, then you can reconfigure the sound output. Otherwise, all that you're listening for is just song data that you send along to the Sound Output Write.

  • How to Ping Hardware via TCP/IP

    I need to ping a device to check connectivity via TCP/IP.  I'm currently using a 3rd party control that has a memory leak.  Is there a way to do this within Labview without using a 3rd Party control?

    [SOLVED]
    Hi
    I need to check several devices by pinging them.
    I don't want to use the windows console method with parsing.
    If I use the ping.llb described under the second link above the labview runtime is crahing latest after 12 hours without any replies. Ping frequency was 400 ms, 1 second would be OK but not nice.
    After all the crashs I decide to use the .net Framework which includes an own Ping class.
    Attached you can find this, at the moment test,  VI which is running in a mini project on my PC.
    For testing purposes I set the delay time constant low, later my wish is something between 400-100ms.
    Problem: If you open the WinXP task manager the used memory of process "labview.exe" is rising rapidly until .net throw an exeption.
    How can I prevent that the memory is rising until a crash occur??? If I reduce the time the memory usage is rising as well, just slow....
    Here is the link to the class description: http://msdn.microsoft.com/en-us/library/system.net.networkinformation.ping.aspx
    Thanks for your help
    Tim
    SOLUTION: I connected the "close reference" on the wrong wire....
    It seems to run even with 0 ms time constant (for testing). I have attached the corrected version.
    Message Edited by computerkammer on 05-17-2008 08:31 AM
    Attachments:
    pingdotnet1.vi ‏17 KB

  • I have problem in transfeering data using field point via tcp

    I am reading the values from the filed point, which is connected, to the RT controller and transferring the values to the client PC via TCP at a specified acquisition rate.
     Case1 when the acquisition rate is 0.1 minutes I get the values from the controller correctly i.e. 5v, 5v, and the chart shows no change. The timed out of the TCP read is default value i.e. is 250ms
     But when I change the acquisition rate to .5 minutes I get the values as 5v, 0v, 5v, and 0v. The time out of the TCP read is same as first case. The inputs to the field point are at the constant 5v.
    Please tell how to solve the problem so as to see the plot in the chart continuously as inputs for the field points the read
    ing are at constant rate of input 5v.

    Suresh,
    Since this question deals with using the LabVIEW TCP/IP functions, you are better off posting it to the LabVIEW discussion forum.
    Regards,
    Aaron

Maybe you are looking for