TCP client server sample

All,
This may not really be a LabWindows/CVI question but I'm really stuck on what should be easy to
solve. The brain trust here on the forums has always been helpful so I'll try to explain.
The project:
Get LabWindows/CVI code talking to a muRata SN8200 embedded WiFi module.
The setup:
(running Labwindows/CVI 2009)
Computer 1 -- (with a wireless NiC) running simple demo TCP server program provided by muRata.
Computer 2 -- USB connection (virtual COM port) with simple program (also provided by muRata) that talks to the SN8200 embedded WiFi module.  This code along with the module creates a simple TCP client.
Whats working:
I can successfuly get the Computer 2 client connected to and talking to the Computer 1 server. (using the muRata supplied code)
I can also run the LabWindows/CVI sample code from (\CVI2009\samples\tcp), server on computer 1 & client on computer 2 and they talk with no problems.
(I'm using the same IP addresses and port numbers in all cases)
Whats NOT working:
Run the CVI server program on computer 1.
I cannot get the muRata client program  to connect to the CVI server.
I also tried get the CVI client program to connect to the muRata server.  No luck that way either. The CVI client sample program trys connect, and this function call:
ConnectToTCPServer (&g_hconversation, portNum, tempBuf, ClientTCPCB, NULL, 5000 );
returns with a timeout error code (-11).
What I need:
Some ideas on how to get this working.
Is there something unique about the LabWindows/CVI sample client/server demo code that would make them incompatible with the muRata code?
Can you think of some ways I can debug this further?  I feel like I'm kind of running blind.
What else can I look at?
For those that have read this far, thanks much and any ideas or comments will be appreciated,
Kirk

Humphrey,
First,
I just figured out what the problem is:
When I was trying to use the CVI sample server I was entering the wrong port number.
The reason I entered the wrong port was because the hard-coded port number in the muRata demo code was displayed in hex as 0x9069. ( I converted this to decimal and entered it into the CVI sample server code) The correct port number was 0x6990.  (upper and lower bytes swapped)  Arrgh!
I found the problem by using the netstat command line utility to display the connections and noted that the port being used was not 0x9069.  It is really a problem with the muRata eval kit demo code.
Second,
Humphrey you are right about the CVI sample code not handling all the muRata commands for the client end of the connection that communicates with the SN8200 module.  For my test I was using the muRata code for that "end".
The server end is simple and the CVI sample is adequate and is now working.
Thank you to all who took the time to browse my questions,
Kirk

Similar Messages

  • Reliable UDP client/server sample

    I need a reliable UDP client/server sample which uses ack,timeout,sequence number, etc. Client and server are different computers in the same network and I need to send a file >10Mb. Where can I find this kind of example? It is required for a project at my university.
    Thanks.

    Can't you use TCP? It already is reliable, has better performance than simple UDP+ACKs (unless you too implement sliding windows), and is a good network citizen (unless you too implement congestion control). Why reinvent the wheel?
    Unless of course your assignment is "reimplement TCP using UDP" in which case you can find the "example" by writing it.

  • Help with MIDlets - TCP client server program

    Hi I am new to using MIDlets, and I wanted to create a simple TCP client server program.. I found a tutorial in J2me forums and I am able to send a single message from server(PC) to client(Phonemulator) and from client to server. But I want to send a stream of messages to the server. Here is my program and I am stuck in the last step wher i want to send lot of messages to server. Here is my program, Could any one of u tell me how to do it? Or where am i going wrong in thsi pgm?
    Code:
    import java.io.InputStream;
    import java.io.IOException;
    import java.io.OutputStream;
    import javax.microedition.io.Connector;
    import javax.microedition.io.SocketConnection;
    import javax.microedition.io.StreamConnection;
    import javax.microedition.lcdui.Alert;
    import javax.microedition.lcdui.AlertType;
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Form;
    import javax.microedition.lcdui.StringItem;
    import javax.microedition.lcdui.TextField;
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.midlet.MIDletStateChangeExcepti on;
    public class SocketMIDlet extends MIDlet
    implements CommandListener, Runnable {
    private Display display;
    private Form addressForm;
    private Form connectForm;
    private Form displayForm;
    private TextField serverName;
    private TextField serverPort;
    private StringItem messageLabel;
    private StringItem errorLabel;
    private Command okCommand;
    private Command exitCommand;
    private Command backCommand;
    protected void startApp() throws MIDletStateChangeException {
    if (display == null) {
    initialize();
    display.setCurrent(addressForm);
    protected void pauseApp() {
    protected void destroyApp(boolean unconditional)
    throws MIDletStateChangeException {
    public void commandAction(Command cmd, Displayable d) {
    if (cmd == okCommand) {
    Thread t = new Thread(this);
    t.start();
    display.setCurrent(connectForm);
    } else if (cmd == backCommand) {
    display.setCurrent(addressForm);
    } else if (cmd == exitCommand) {
    try {
    destroyApp(true);
    } catch (MIDletStateChangeException ex) {
    notifyDestroyed();
    public void run() {
    InputStream is = null;
    OutputStream os = null;
    StreamConnection socket = null;
    try {
    String server = serverName.getString();
    String port = serverPort.getString();
    String name = "socket://" + server + ":" + port;
    socket = (StreamConnection)Connector.open(name, Connector.READ_WRITE);
    } catch (Exception ex) {
    Alert alert = new Alert("Invalid Address",
    "The supplied address is invalid\n" +
    "Please correct it and try again.", null,
    AlertType.ERROR);
    alert.setTimeout(Alert.FOREVER);
    display.setCurrent(alert, addressForm);
    return;
    try {
    // Send a message to the server
    String request = "Hello\n\n";
    //StringBuffer b = new StringBuffer();
    os = socket.openOutputStream();
    //for (int i=0;i<10;i++)
    os.write(request.getBytes());
    os.close();
    // Read the server's reply, up to a maximum
    // of 128 bytes.
    is = socket.openInputStream();
    final int MAX_LENGTH = 128;
    byte[] buf = new byte[MAX_LENGTH];
    int total = 0;
    while (total<=5)
    int count = is.read(buf, total, MAX_LENGTH - total);
    if (count < 0)
    break;
    total += count;
    is.close();
    String reply = new String(buf, 0, total);
    messageLabel.setText(reply);
    socket.close();
    display.setCurrent(displayForm);
    } catch (IOException ex) {
    Alert alert = new Alert("I/O Error",
    "An error occurred while communicating with the server.",
    null, AlertType.ERROR);
    alert.setTimeout(Alert.FOREVER);
    display.setCurrent(alert, addressForm);
    return;
    } finally {
    // Close open streams and the socket
    try {
    if (is != null) {
    is.close();
    is = null;
    } catch (IOException ex1) {
    try {
    if (os != null) {
    os.close();
    os = null;
    } catch (IOException ex1) {
    try {
    if (socket != null) {
    socket.close();
    socket = null;
    } catch (IOException ex1) {
    private void initialize() {
    display = Display.getDisplay(this);
    // Commands
    exitCommand = new Command("Exit", Command.EXIT, 0);
    okCommand = new Command("OK", Command.OK, 0);
    backCommand = new Command("Back", Command.BACK, 0);
    // The address form
    addressForm = new Form("Socket Client");
    serverName = new TextField("Server name:", "", 256, TextField.ANY);
    serverPort = new TextField("Server port:", "", 8, TextField.NUMERIC);
    addressForm.append(serverName);
    addressForm.append(serverPort);
    addressForm.addCommand(okCommand);
    addressForm.addCommand(exitCommand);
    addressForm.setCommandListener(this);
    // The connect form
    connectForm = new Form("Connecting");
    messageLabel = new StringItem(null, "Connecting...\nPlease wait.");
    connectForm.append(messageLabel);
    connectForm.addCommand(backCommand);
    connectForm.setCommandListener(this);
    // The display form
    displayForm = new Form("Server Reply");
    messageLabel = new StringItem(null, null);
    displayForm.append(messageLabel);
    displayForm.addCommand(backCommand);
    displayForm.setCommandListener(this);

    Hello all,
    I was wondering if someone found a solution to this..I would really appreciate it if u could post one...Thanks a lot..Cheerz

  • TCP Client - Server Prog.

    Hi All,
    I have posted TCP client- server prog. I have trouble in client code. When i'm running the server code on some port and the running the client code on the same port, then client is sending message to server(in this case integers with space like 12 22 23) , the server is receiving the message and adding the sum and sending the sum to client, but when i'm trying to read the stream from server(i.e the sum), i'm getting nothing.........
    please run the code and check.......u can understand well....
    please reply me as soon as possible.
    Thanks
    import java.io.*;
    import java.net.*;
    class TCPAdditionClient
         public static void main(String args[]) throws Exception
         {   Character ans = null;
              String hostname="localhost";
              String sentence;
              String result;
              int port=0;
              if (args.length > 0) {
              try {
              port = Integer.parseInt(args[0]);
              } catch (NumberFormatException e) {
              System.err.println("Argument must be an integer");
              System.exit(1);
              Socket clientSocket = new Socket(hostname,port);
              do
                   System.out.println("Enter the number of integers....");
                   BufferedReader fromUser = new BufferedReader(new InputStreamReader(System.in));
                   sentence = fromUser.readLine();
                   DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream());
                   //System.in.read();
                   outToServer.writeBytes(sentence + '\n');
                   System.out.println("server sends message");
                   BufferedReader fromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
                   System.out.println(fromServer);
                   result = fromServer.readLine();
                   System.out.println("from Server" + result);
                   System.out.println("Do u want to continue y/n");
              }while(! ans.equals("n"));
              clientSocket.close();
    import java.io.*;
    import java.util.*;
    import java.net.*;
    class TCPAdditionServer
         public static void main(String args[]) throws Exception
              String clientSentence;
              int port=0;
              if (args.length > 0) {
              try {
              port = Integer.parseInt(args[0]);
              } catch (NumberFormatException e) {
              System.err.println("Argument must be an integer");
              System.exit(1);
              ServerSocket welcomeSocket = new ServerSocket(port);
              while(true)
                   int sum = 0,total_sum = 0;
                   Socket connectionSocket = welcomeSocket.accept();
                   BufferedReader fromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream()));
                   DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream());
                   clientSentence = fromClient.readLine();
                   System.out.println(clientSentence);
                   String[] result = clientSentence.split(" ");
                   for (int x=0; x<result.length; x++)
                        sum = Integer.parseInt(result[x]);
                        total_sum = sum + total_sum;
                        System.out.println(total_sum);
                   String sendData = "from the server" + "sum :" + total_sum;
                   System.out.println(sendData);
                   outToClient.writeBytes(sendData);
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    can u explain it http://www.catb.org/~esr/faqs/smart-questions.html#writewell
    How To Ask Questions The Smart Way
    Eric Steven Raymond
    Rick Moen
    Write in clear, grammatical, correctly-spelled language
    We've found by experience that people who are careless and sloppy writers are usually also careless and sloppy at thinking and coding (often enough to bet on, anyway). Answering questions for careless and sloppy thinkers is not rewarding; we'd rather spend our time elsewhere.
    So expressing your question clearly and well is important. If you can't be bothered to do that, we can't be bothered to pay attention. Spend the extra effort to polish your language. It doesn't have to be stiff or formal - in fact, hacker culture values informal, slangy and humorous language used with precision. But it has to be precise; there has to be some indication that you're thinking and paying attention.
    Spell, punctuate, and capitalize correctly. Don't confuse "its" with "it's", "loose" with "lose", or "discrete" with "discreet". Don't TYPE IN ALL CAPS; this is read as shouting and considered rude. (All-smalls is only slightly less annoying, as it's difficult to read. Alan Cox can get away with it, but you can't.)
    More generally, if you write like a semi-literate b o o b you will very likely be ignored. So don't use instant-messaging shortcuts. Spelling "you" as "u" makes you look like a semi-literate b o o b to save two entire keystrokes.

  • TCP Client Server - how to set timeout and bandwidth option

    Hi Friends,
    I am writing a simple TCP based client-server app and I would like the connection to be dropped after a certain time of inactivity and also I would like to control the connection's bandwidth. I would appreciate if someone can throw some pointers as to how this can be done.
    I have tried this so far, for Timeout I am trying to do this:
    sock.setSoTimeout(10000);But I think this is not the right way as this will disconnect the server from all client connections I guess. I think the better way would be to write a timer or something for each connection but I don't know how...
    Any help?

    Micks80 wrote:
    Hi Friends,
    I am writing a simple TCP based client-server app and I would like the connection to be dropped after a certain time of inactivity and also I would like to control the connection's bandwidth. I would appreciate if someone can throw some pointers as to how this can be done.
    I have tried this so far, for Timeout I am trying to do this:
    sock.setSoTimeout(10000);But I think this is not the right way as this will disconnect the server from all client connections I guess.Wrong in a couple of ways.
    1) That doesn`t disconnect anything. It causes a read that reaches that time in blocking to be unblocked and an exception (java.net.SocketTimeoutException) is thrown. The Socket is still just fine and can be used (all other things being equal). At any rate you then decide what you want to do after a timeout. One possibility is to close the socket because to you that timeout means it is abandoned.
    2) setSoTimeout of ServerSocket applies to the accept* method. setSoTimeout of Socket applies to reads from that sockets input stream. Neither of those apply anything to all connections.
    I think the better way would be to write a timer or something for each connection No setSoTimeout is correct. You will also then need to actually attempt to read something for that timeout exception to ever be thrown.
    As far as the bandwidth question goes, you will need to define your goals better. Please do not just restate "control bandwidth" because that is not actually a very specific goal. Do you want to limnit the bandwidth used at one time (tricky) or do you want to limit the total bandwidth used. Either way requires some work but they are different things.

  • TCP Client/Server Whiteboard - Like Netmeeting - Need advice

    I won't get into details of the full project, but one part of the project is a whiteboard-like VI that works similar to the whiteboard in Netmeeting. I created a quick server and client VI to establish a TCP connection to allow the whiteboard to run for everyone. Run the server VI first and then the client VI and the whiteboards will open. Normally you would only have one whiteboard running, but this is a demo to allow the client and server to run on the same computer. Please execute the project to understand what the program does so that you understand the concept.
    Now for my problem: I spent a several days designing this portion of my project and it is fairly usable, but the problem is that if you continuously draw on the screen for a long time (maybe 1 minute), the arrays will get rather large and will eventually slow the drawing process to a crawl. In a previous version I would draw to the screen, feedback the picture element, and then clear the array, thinking this would be the most efficient. Unfortunately it seemed to be pretty slow also.
    I've only been using Labview for a year, so please forgive me if my code is sloppy or if I did things in a weird way. This is why I am posting this code. I'm really looking for advice on optimizing the code and fixing my main problem.
    Attachments:
    Whiteboard.zip ‏413 KB

    Hi Travis,
    Thanks for your reply. I saw your post after I already solved the problem otherwise I would look into your suggestions. I thought I would post the solution here so that this code might help someone in the future.
    To recap, I had a problem with a drawing slowdown using two different methods. The first method was to draw to a picture element and then loop this around the main while loop and then draw to the picture element again for every pixel movement captured. Reloading the picture element rapidly was a major drag on the CPU. So the second method I used was to store all pixels movements captured in an array and add another array to the second dimension every time the mouse button lifted. I would draw EVERYTHING in this 2D array everytime I looped around. This meant that the array could get rather large after a very short time and bog down the CPU.
    So I realized that I could take the best of both methods mentioned and use a nested while loop inside another while loop. The outer while loop shifts the picture element around and the inner loop will continue to build and redraw only one row of the array until the mouse button is up. At this point I stop the inner loop and pass the picture element around null the arrays for the inner loop. Seems to accomplish everything I needed.
    Hope this can help somebody else. The new code is attached
    Attachments:
    Whiteboard.zip ‏515 KB

  • TCP client server

    hi,
    how do i do this:
    Create a Server Program in TCP
    Create a file with some data.
    Create a Client Program in TCP
    Establish a connection with the server
    On establishment, the server should read the data from the file and write onto the socket of the client.
    The client has to read the data from the socket and write onto a different file.

    hi,
    this is the server code that i have.
    import java.io.*;
    import java.net.*;
    public class fileServer {
    public fileServer() {
    int i=1;
    try {
    ServerSocket s = new ServerSocket(5000);
    System.out.println("Server Started...");
    Socket incoming = s.accept();
    Thread t = new ThreadedServer(incoming, i);
    i++;
    t.start();
    }catch(Exception e){
    System.out.println("Error: "+e);
    public static void main(String args[]){
    new fileServer();
    class ThreadedServer extends Thread{
    int n;
    Socket fileSocket;
    int count;
    public ThreadedServer(Socket i, int c){
    fileSocket = i;
    count = c;
    public void run(){
    BufferedReader buffRead = null;
    OutputStream os;
    try{
    File f = new File("file1.txt");
    FileInputStream fis = new FileInputStream(f);
    os = fileSocket.getOutputStream();
    int buffSize = 4096;
    byte[] buff = new byte[buffSize];
    int count = 0;
    while((count = fis.read(buff))>= 0) {
    os.write(buff,0,(int)count);
    System.out.println(os);
    fis.close();
    os.close();
    }catch(IOException ioe) {
    System.out.println("this is a IOException"+ioe.getMessage());
    This is the client code that i have:
    import java.io.*;
    import java.net.*;
    public class fileClient{
    public static void main(String args[]){
    Socket clientSocket;
    PrintStream out = null;
    BufferedReader in = null;
    try{
    clientSocket = new Socket("10.45.2.34",5000);
    System.out.println("connection established");
    out = new PrintStream(clientSocket.getOutputStream());
    in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
    String text = in.readLine();
    System.out.println(text);
    in.close();
    out.close();
    }catch (UnknownHostException e){
    System.err.println("unidentified hostname");
    System.exit(1);
    }catch(IOException ioe) {
    System.err.println("couldnt get I/O");
    System.exit(1);
    The above code works fine,but the final step i.e the client has to read the data from the socket and write onto a different file is not performed.
    So how do i proceed from here.

  • Async tcp client and server. How can I determine that the client or the server is no longer available?

    Hello. I would like to write async tcp client and server. I wrote this code but a have a problem, when I call the disconnect method on client or stop method on server. I can't identify that the client or the server is no longer connected.
    I thought I will get an exception if the client or the server is not available but this is not happening.
    private async void Process()
    try
    while (true)
    var data = await this.Receive();
    this.NewMessage.SafeInvoke(Encoding.ASCII.GetString(data));
    catch (Exception exception)
    How can I determine that the client or the server is no longer available?
    Server
    public class Server
    private readonly Dictionary<IPEndPoint, TcpClient> clients = new Dictionary<IPEndPoint, TcpClient>();
    private readonly List<CancellationTokenSource> cancellationTokens = new List<CancellationTokenSource>();
    private TcpListener tcpListener;
    private bool isStarted;
    public event Action<string> NewMessage;
    public async Task Start(int port)
    this.tcpListener = TcpListener.Create(port);
    this.tcpListener.Start();
    this.isStarted = true;
    while (this.isStarted)
    var tcpClient = await this.tcpListener.AcceptTcpClientAsync();
    var cts = new CancellationTokenSource();
    this.cancellationTokens.Add(cts);
    await Task.Factory.StartNew(() => this.Process(cts.Token, tcpClient), cts.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default);
    public void Stop()
    this.isStarted = false;
    foreach (var cancellationTokenSource in this.cancellationTokens)
    cancellationTokenSource.Cancel();
    foreach (var tcpClient in this.clients.Values)
    tcpClient.GetStream().Close();
    tcpClient.Close();
    this.clients.Clear();
    public async Task SendMessage(string message, IPEndPoint endPoint)
    try
    var tcpClient = this.clients[endPoint];
    await this.Send(tcpClient.GetStream(), Encoding.ASCII.GetBytes(message));
    catch (Exception exception)
    private async Task Process(CancellationToken cancellationToken, TcpClient tcpClient)
    try
    var stream = tcpClient.GetStream();
    this.clients.Add((IPEndPoint)tcpClient.Client.RemoteEndPoint, tcpClient);
    while (!cancellationToken.IsCancellationRequested)
    var data = await this.Receive(stream);
    this.NewMessage.SafeInvoke(Encoding.ASCII.GetString(data));
    catch (Exception exception)
    private async Task Send(NetworkStream stream, byte[] buf)
    await stream.WriteAsync(BitConverter.GetBytes(buf.Length), 0, 4);
    await stream.WriteAsync(buf, 0, buf.Length);
    private async Task<byte[]> Receive(NetworkStream stream)
    var lengthBytes = new byte[4];
    await stream.ReadAsync(lengthBytes, 0, 4);
    var length = BitConverter.ToInt32(lengthBytes, 0);
    var buf = new byte[length];
    await stream.ReadAsync(buf, 0, buf.Length);
    return buf;
    Client
    public class Client
    private TcpClient tcpClient;
    private NetworkStream stream;
    public event Action<string> NewMessage;
    public async void Connect(string host, int port)
    try
    this.tcpClient = new TcpClient();
    await this.tcpClient.ConnectAsync(host, port);
    this.stream = this.tcpClient.GetStream();
    this.Process();
    catch (Exception exception)
    public void Disconnect()
    try
    this.stream.Close();
    this.tcpClient.Close();
    catch (Exception exception)
    public async void SendMessage(string message)
    try
    await this.Send(Encoding.ASCII.GetBytes(message));
    catch (Exception exception)
    private async void Process()
    try
    while (true)
    var data = await this.Receive();
    this.NewMessage.SafeInvoke(Encoding.ASCII.GetString(data));
    catch (Exception exception)
    private async Task Send(byte[] buf)
    await this.stream.WriteAsync(BitConverter.GetBytes(buf.Length), 0, 4);
    await this.stream.WriteAsync(buf, 0, buf.Length);
    private async Task<byte[]> Receive()
    var lengthBytes = new byte[4];
    await this.stream.ReadAsync(lengthBytes, 0, 4);
    var length = BitConverter.ToInt32(lengthBytes, 0);
    var buf = new byte[length];
    await this.stream.ReadAsync(buf, 0, buf.Length);
    return buf;

    Hi,
    Have you debug these two applications? Does it go into the catch exception block when you close the client or the server?
    According to my test, it will throw an exception when the client or the server is closed, just log the exception message in the catch block and then you'll get it:
    private async void Process()
    try
    while (true)
    var data = await this.Receive();
    this.NewMessage.Invoke(Encoding.ASCII.GetString(data));
    catch (Exception exception)
    Console.WriteLine(exception.Message);
    Unable to read data from the transport connection: An existing   connection was forcibly closed by the remote host.
    By the way, I don't know what the SafeInvoke method is, it may be an extension method, right? I used Invoke instead to test it.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • TCP client communicating with UDP server

    Hello,
    I want to make a TCP client to communicate with an UDP server. Does anyone know a way of doing this? I am not interested in reliable data transfer. So I don't care if the datagram is lost. I want to make the UDP server accept some datagrams from the TCP client. Also, the datagram that I want to transmit is less than 65,536 octets so it is not devided to several datagrams. Therefore, only one exchange procedure occurs.
    I made an UDP server using DatagramSocket and DatagramPacket classes and a TCP client using Socket class, but the TCP client informs me that the connection was refused.
    Any ideas?

    Let's google for IP header and the first hit is http://www.networksorcery.com/enp/protocol/ip.htm (Whoa! Classic page! I must have seen that back when googling was called altavista.)
    There is a header field, a single byte, called protocol. For TCP/IP that field contains 6, for UDP/IP it contains 17.
    If you send a packet with protocol=17, the receiving host's kernel will check if it has an process listening to UDP (17) at the port specified in the packet header. No such process? Then simply discard the packet. So you can't send an UDP packet to a TCP socket because the protocol field is wrong.
    If you want to fake a TCP stream you could look into jpcap, which allows you to capture and send raw packets. Google for it; and pick the right jpcap, there are two, only one of which (AFAIK) can send packets. Attempting to write your own TCP implementation is highly advanced though, and not really practical.

  • Handle Received data of Multiple TCP clients on TCP Server by displaying them into Datagrid

    Hello All,
    I have developed a C# based TCP server GUI application which is accepting the data from multiple TCP clients on TCP server.
    The data i am receiving from TCP clients is a 32 bit data. In my application multiple TCP client data goes like this:
    00012331100025123000124510321562
    01112563110002512456012451032125 and so on...
    Now i want those data of the TCP clients to be parsed into 4 bits first and display it in 8 columns (32/4=8) of (say) datagrid as each 4 bit represents some characteristics of the TCP client. The same thing
    should work for next TCP client on second row of datagrid.            
    Can you give me some suggestion or an example how to go about this? Any help would be appreciated.
     Thank you in advance.
    Here is my code for receiving data from multiple TCP clients.
    void m_Terminal_MessageRecived(Socket socket, byte[] buffer)
    string message = ConvertBytesToString(buffer, buffer.Length);
    PublishMessage(listMessages, string.Format("Sockets: {0}", message));
    // Send Echo
    // m_ServerTerminal.DistributeMessage(buffer);
    private string ConvertBytesToString(byte[] bytes, int iRx)
    char[] chars = new char[iRx + 1];
    System.Text.Decoder d = System.Text.Encoding.UTF8.GetDecoder();
    d.GetChars(bytes, 0, iRx, chars, 0);
    string szData = new string(chars);
    return szData;

    Now i want those data of the TCP clients to be parsed into 4 bits first and display it in 8 columns (32/4=8) of (say) datagrid as each 4 bit represents some characteristics of the TCP client. The same thing
    should work for next TCP client on second row of datagrid
    If mean it's a Windows Forms application and you want to display those bits in a DataGridView control, then please see these threads:
    Add row to datagridview
    Programmatically add new row to DataGridView
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Help needed on TCP/IP Multi-port Client-Server

    Hi all, I am trying to develop a client-server application to stream some data over a few random port numbers (defined by myself) to stream data over to the TCP server (i.e another computer) in LabVIEW. So far, I have created my application using the NI examples for "Simple Data Client + Server" and it works fine. I also understand that the "TCP Listen" VI is only able to listen for 1 TCP connection only and a way around this is to use queueing idea to receive & process the incoming data.The downside to the idea is that the "base port" (i.e initial port) needs to be the same (on every TCP client) with the TCP Server and it is not fit for the purpose I intended.
    Basically on the TCP server side, i need to chart/monitor the data on different port numbers that is being streamed real-time from the one TCP client computer. Is this possible in LabVIEW?
    Can anyone (incl. NI gurus) advise and point me in the right direction?
    *lost*
    Solved!
    Go to Solution.

    Hi
        http://zone.ni.com/devzone/cda/epd/p/id/2739 Here you can download that component.But you can also use TCP icons which is available in Data Commmunications>Protocals>TCp for communication and to read and write data use variant to flattened string. I have attached a small example where i will transfer a constant string to the host PC to check the link between client and the server. Hope this helps you.
    Attachments:
    TCP Comm.zip ‏47 KB

  • My Tcp/ip multi-client server is not passing the data string into the flatten to string vi

    I am using labview Multi-connection cleint and server to build my own multi-client server connection.
      The problem i am having is that the data does not get through the flatten to string vi. Would anyone be kind enough to tell me why is that happening? and what I do to fix it.
      Attached code . My goal is to send data to the client via tcp/ip and use the data to perform certain task.
      Thanks a whole lot
    Attachments:
    multiconnection-server.vi ‏39 KB
    multiconnection-client.vi ‏21 KB

    Instead, I decided to upload the code and recent mods I have made to it .
    see attached
    Attachments:
    multiconnection-clienttest.vi ‏43 KB
    multiconnection-servertest.vi ‏21 KB

  • Client-Server receive/send with TCP (high data rates)

    hello ,
    i want to test client -server one way throughput with TCP , any one can give me more hint about it ??

    Don't start a new thread if it's still about the same question.
    Especially when you add no new information.
    Show us the code you're currently using [in your original thread|http://forums.sun.com/thread.jspa?threadID=5434178&start=25].

  • JavaFX as a SaaS/ How good is it for Client-Server work?

    I was under the impression that FX could be used to produce a Client-Server application as well as SaaS.
    a member of another forum said "I'm sure you meant to say "Desktop". JavaFX will not be making inroads on the web as a client-side technology."
    To which I said
    There have been examples of FX used with EE
    http://www.oracle.com/technetwork/java/javafx/samples/index.html
    http://docs.oracle.com/javafx/2/overview/jfxpub-overview.htm
    Sales Dashboard (DataApp)
    DataApp is a client-server application for a fictional global automobile company called Henley Car Sales. Automobile sales are simulated on an EJB server using JavaDB, and the data is available via Derby and a RESTful web service. The client demonstrates a variety of data presentations by using a mix of FXML and JavaFX.
    I thought originally that JavaFX was "Desktop" only also, until I found this example. I couldn't get it to run due to some weird Database line read issue that others also had. I'm not sure if this is now due to FX's integration, or if this was something new, but I believe I have seen another FX client-server app as well.
    I'm not that familiar with the client-server side of Java yet, so if you have other Information I would like to know, because I am looking to design a Client-Server app with FX, and I don't see why it would be an issue, unless there are huge limitations."
    He ended up saying "Those are still desktop apps. Sure, they are client-server in that they connect to a remote database. But they are still traditional fat-client apps rather than web-based thin-client SAAS web applications which, these days, most people will think of when you say "client".
    My point is to be more precise when you use the word "client".
    But if your point is just that JavaFX is taking over from Swing for the limited areas in which Swing is used, I have no insight into that area."
    Now I don't really like attitudes when I get my question answered, but the high and mighty needs to stop. It clearly says Client-Server so I don't know why it's being denounced by this dude who thinks he obviously knows better.
    Anyways he talks about it only being able to connect to a DB, to which it says it uses EE tech such as EBJ, Restful, and Derby, so that's more than just DB right(I don't know since I havent' learned that yet)?
    It seems as if he's saying that only EE code can go up on a server? Or can SE code go up there as well?
    I'm looking to design a SaaS software with FX, so if this isnt' possible I would like to know possible other options(or just having all of the gui work on the client, and the rest on the backend)???
    Thanks!
    ~KZ
    Edited by: KonradZuse on Apr 30, 2013 11:26 AM

    This response is not a tutorial, I hope it gives you some verbiage to use in further searches.
    SaaS to me means that the service is running on the server. If you have the server and permission to run java apps there then you can use Java FX by having the server shuttle requests to the Java FX app. But this is probably not the intent of Saas (it would be more appropriate to use a java implemented web service).
    If you are using Netbeans then it is very easy to create demo projects; use "File/New Project" to run them on your local computer.
    Example File/New Project/Java Web/Web Application will give you a hello world web site very quickly. This will 1) start either tomcat or glassfish as the server. 2) launch an html page with "hello world". then you can use java script to talk with the server via ajax. Using this approach you are going to need to study JSP or J2EE stuff.
    After this is running you could start one of the Java Fx examples in Netbeans: File / New Project / Samples / WebViewBrowser. This will start a javaFX app that acts like a browser and runs on the client.
    So, start the "hello world" app in netbeans by right clicking it in the project pain and selecting "debug". Then start the webviewBrowser app the same way to load that web page that has "hello world" in it as all browsers do. In the WebviewBrowser (which is java fx) you can get at the javascript in the web page and do all kinds of stuff. You'll need to search for webviewBrowser examples.
    The above all assumes a Netbeans solution. But, as you probably know, there are no rules. The server can be in C++ and the client in C (or any other language). The server and client usally communicate via http or tcp. So you could have a server written in java (maybe J2ee or you can rewrite a http server from scratch which isn't that hard - search for "HttpServletRequest and HttpSession" ) and the client can be in Java FX (where the Java FX talks directly with the server via http (no javascript or web page in the middle) again there are probably hundreds of libraries to talk to a http server).
    I use HttpServletRequest and HttpSession on the server side with MySQL and xml. On the client I use javaScript but I am moving to a strictly Java FX solution. This will give me close to 100% java on both sides and for my purposes this will work. (I may need a little html in the middle for drag and drop installation.) I am hoping that work continues with porting Java FX to most devices: Android, IOS, WinPhone. It is already on Linux, Windows Desktops and Mac.
    Edited by: KevinPas on May 1, 2013 9:50 AM
    Edited by: KevinPas on May 1, 2013 9:56 AM

  • Client/Server API with push?

    I set up a simple Socket client server architecture with the Java socket API. However, my clients sometimes are initiators or requests, and sometimes my server is the initiator of infos. Example: client want to get infos from server but also want to tell the server something. The server tells all registered clients something but also can accept requests from clients. So both sides are client AND server (depending on what they currently want to do).
    The socket API is just a classic client/server API, i.e. a server listens and a client sends requets and get responses. For my server to send requests to all clients, this is not enough. Is the only way to have all clients offering a socket server on their computer, too? so that this 2-way-request-communication works?
    This is basically some kind of "push" technology, but i don't want my clients to "poll" the server just to emulate the feature of sending requests from the server to the client. Is there some other (perhaps non-socket) API that offers this?

    @sjasja: how is the socket api symmetrical?It is, trust me! Connection initiation isn't, but after that it is. (Let's assume connected TCP/IP.)
    The server does bind() and accept(), the client does connect(). After that, the connection is symmetrical: either end can issue any number of read() and write() calls in any order. You write() to a socket, it pops out from read() at the other end (though not necessarily as a single packet; TCP/IP is stream oriented, so write() "packets" can and will be glued together, or fragmented at the whimsy of network routers and friends.)
    - accept() //wait for client to send request
    - socket.getInputStream() //read request
    - socket .getOutputStream() //write responseThose don't read or write; they get streams which you can read from and write to.
    In the server, when accept() returns a new connection, you'd start a reader thread for that client. The thread would read() (or readLine() if you implement a line-oriented protocol) and handle the incoming messages. Whenever you want to write to the client, write to the stream returned by socket.getOutputStream(). You may need to synchronize writes if you have several threads that do sequences of write()s that need to arrive at the client sequentially.
    As to the difficulty of socket programming: I don't think it particularly difficult. But then I've written dozens of socket programs since my first one in '85... The Java Tutorial socket chapter shows a simple client/server pair; not terribly difficult I think. In particular, check out the KKMultiServer at the bottom of the sample server chapter.

Maybe you are looking for

  • Rotated image at 120% zoom

    Hi Framers, I use Frame 7.1p116 and have some small graphics of arrows in my text. These are imported by reference, Anchored Frame, At Insertion Point. When I display at 100% ot 140% (or other values) the display is just fine. But at 120% one of the

  • Product Cost Collectors not settled to GL's during Period end Close

    Hi, We are using the repetative manufacturing process. We have an issue with our repetative manufacturing orders, during the monthly period end close.The product cost collectors WIP is not been settled to GL's. The normal production orders are been s

  • Two MDB Listen on same topic

    Dear All, If I configure two separate MDBs to listen on the same Topic using Oracle JMS (i.e have a multi-consumer queue table,...), will each MDB receive the same message or will only the first MDB to have its onMessage method fired by the container

  • How to open projects within a zip file?

    Is there any way to use the open project feature to open projects within a zip file loaded onto a LMS?  I have several files loaded in a zip file and I would like to navigate to each one within the zip file itself.  The problem that I see is that it

  • Any third party streetview app for ios 6?

    Hi everybody! Strongly missing the old Google streetview, but apparently it is no longer available in ios6, not even in the Google Maps that got issued to fit ios 6. Any suggestion as to a replacement is welcome! Is there any third party program that