How do I send strings over a TCP/IP LAN N/W

I want to send string information over LANs which can be viewed on Hyperterminal in PCs on the N/W
Pls help me out
Solved!
Go to Solution.

Are you trying to broadcast a message on your LAN? If so you'd need to use UDP (since it's a connectionless protocol) and use the broadcast address for your subnet. You'd have to check with your network admin as to what that is, though it's probably x.x.x.255 or 255.255.255.255. TCP requires a connection so for TCP/IP you'd need to send the message to each individual IP address. Alternatively, if you're on Windows you could use the "net send" command using System Exec.

Similar Messages

  • Sending Strings Over GKSession - How to stop some craziness?

    Sounds simple, right? But the tricky part is I am trying to retain the header structure from GKTank... I am quite desperate for help at this point as I've been flailing around on this all day and all night....
    All my other events use this structure already and work just fine..and after a ton of trial and error I'm very close... hoping I can get one of you experts to take a look. The issue is that when my strings are less than 8 characters, the results get very strange....
    Here's the relevant code: (kMaxPacketSize is a constant of 1024)
    To send Data: (this is straight from GKTank, actually)
    - (void)sendNetworkPacket:(GKSession *)session packetID:(int)packetID withData:(void *)data ofLength:(int)length reliable:(BOOL)howtosend {
    static unsigned char networkPacket[kMaxPacketSize];
    const unsigned int packetHeaderSize = 2 * sizeof(int); // we have two "ints" for our header
    if(length < (kMaxPacketSize - packetHeaderSize)) { // our networkPacket buffer size minus the size of the header info
    int *pIntData = (int *)&networkPacket[0];
    // header info
    pIntData[0] = packetNumber++;
    pIntData[1] = packetID;
    // copy data in after the header
    memcpy( &networkPacket[packetHeaderSize], data, length );
    NSData *packet = [NSData dataWithBytes: networkPacket length: (length+8)];
    if(howtosend == YES) {
    [session sendDataToAllPeers:packet withDataMode:GKSendDataReliable error:nil];
    } else {
    [session sendDataToAllPeers:packet withDataMode:GKSendDataUnreliable error:nil];
    In this particular case, I began by calling the above method thusly:
    NSString *myText = self.myLabel.text
    NSInteger len = [myText length];
    [self sendNetworkPacket:mySession packetID:NETWORKTEXTEVENT withData:myText ofLength:(len*2)+1 reliable:YES];
    and unwrapping like this on the other end:
    NSString *pStringData = (NSString *)&incomingPacket[8];
    Works like a charm... strings show up just fine on the other device.... except when the string is less than 8 characters...this causes crashes of EXCBADACCESS on the receiving device. When I check values for these short strings prior to sending over GKSession, the memcpy command does not properly embed the string into 'networkPacket' and keeps remnants from the last string that was transmitted.
    So, in an attempt to work around what is probably a flaw in my logic, I decided to see what happens if I pad the beginning and end of these short strings to make them over 8 characters, by defining another string 'spacer' and then sending a padded string instead of myText:
    NSString *spacer = @"zZzZ";
    NSString *bufText = [spacer stringByAppendingString:[myText stringByAppendingString:spacer]];
    len = [bufText length];
    [self sendNetworkPacket:mySession packetID:NETWORKTEXTEVENT withData:bufText ofLength:(len*2)+1 reliable:YES];
    This got rid of the issues with memcpy, and now all strings are embedded in 'networkPacket' properly, some just have the spacers on the beginning and end... no problem, right? I figured I'd just filter out the spacers on the other end, but guess what? I have even tried using the same code to disassemble the packet, prior to sending it, exactly the way I do on the receiving device... it disassembles fine, and I can re-create the string from the raw packet I send....
    However... (and this ONLY happens on the strings that have been padded) when I receive the data through GKSession I get totally random characters and even lengths! Sometimes I get odd system strings like 'tpenable' or 'uni0164' ... it's so bizarre... I don't understand what is making the padded strings get treated differently.... I tried padding all strings just to check and then they all act like this when transmitted... and again when I use the following code, prior to sending the packet, both test1 and test2 look fine:
    NSString *test1 = (NSString *)&networkPacket[8];
    unsigned char *testPacket = (unsigned char *)[packet bytes];
    NSString *test2 = (NSString *)&testPacket[8];
    NSLog (@"netPacket");
    NSLog (test1);
    NSLog (@"Packet");
    NSLog (test2);
    If you have any ideas, I'd really appreciate it!
    Message was edited by: Tech Guru

    [dataString bytes] returns a +const void*+ type. The compiler is complaining because you passed that +const void*+ pointer to a method that declared the 3rd arg to be a void*. The difference between the two pointers is that the first type doesn't want you to change the bytes that it's pointing to, while the second type doesn't care.
    For example:
    - myMethod:(const char *)foo {
    foo[3] = 'A'; // changing the value of the 4th byte at address foo
    In the above, the compiler should warn that your method changed the data which was referenced by a const char* type.
    But sendNetworkPacket doesn't do anything naughty like the above, it just copies the data at the given addy into a buffer. So you could have declared the data param as const void* like this:
    - (void)sendNetworkPacket:(GKSession *)session packetID:(int)packetID withData:(const void *)data ofLength:(int)length reliable:(BOOL)howtosend;
    The above change should get rid of the warning. If the compiler thinks you're changing that data in sendNetworkPacket (we know you're not doing that, but it's hard to argue with a compiler), you'll then get a new warning to that effect. In that case you might as well put a type cast in the call. I.e. take 'const' back out of the method declaration, and cast the arg in the call like this:
    [self sendNetworkPacket:mySession packetID:NETWORKTEXTEVENT withData:(void*)[dataString bytes] ofLength:len reliable:YES];
    The first try is preferable, since we like to avoid type casts, and since (I assume) sendNetworkPacket really doesn't want to change that data. But if the compiler won't cooperate, the second way will always work for you.
    Btw, putting the text into a NSData object is fine by me, but you could've also used any number of NSString methods that aren't deprecated (e.g. [myText UTF8String]). No need to go there now though. I'm guessing your early problems with some perfectly good methods were due to data type glitches. Because of mismatched data types, you may have abandoned the correct approach and gone down the wrong path.
    Once things got to the point where a NSString pointer was sent to memcpy, I think all of us were at risk of falling into darkness. I stared at the code for a very long time, wondering if everyone in the World but me knew that trick. Next time you get a data type error, maybe post the code here and let us try and help out while the problem is still easy to solve, ok?
    All the best,
    Ray

  • How do I send music over Firewire on an iMac?

    We have an iMac set up with a PreSonus digital PA mixer in our church.  Sending iTunes music over the stereo audio output from the iMac to the mixer is noisy.  We have a Firewire input on the mixer, and the input channel on the mixer has an ability to receive music and other content over Firewire.  We've tried just pluggin in the FireWire cable, but it doesn't seem to be able to send music that way.
    How can I set up the output section of iTunes to music over FireWire?
    thanks so much.

    If your late 2009 IMac is the 21.5 inch screen model, the GPU cannot be changed at all as it is soldered to iMac's logic board.
    If you have the 27 inch screen model, then Kappy is correct.
    The GPU chip is a removable, replaceable socketed chip but it can only be replaced with a GPU chip that has the same socket configuration as the actual GPU socket the GPU chip sets in is NOT replaceable and is soldered to the IMac's GPU card.
    There were only two GPU chips that can be used/accepted in a 27 inch screen, late 2009 IMac model, a 256 MB VRAM GPU and a 512 MB VRAM GPU.
    You can only use GPU chips that were available for a particular IMac model year.
    The 2009 512 MB VRAM GPU chip is very hard to find and very expensive to purchase and the installation should be done by Apple OR an Authorised Apple Service provider adding additional cost.
    The total cost of replacing your iMac's GPU could be upwards of $500+ U.S.D.

  • How do I send string data into DIAdem via a channel?

    Using a TO.DATASHEET reference, ChnValSet doesn't work with strings. It's fine with numbers and dates, just not strings. I'm not sure if the CHT variable is useful for me or not. Thanks.

    Hi Deca,
    You can use the CmdExecuteSync method of the DIAdem.TOCommand interface to set the value of a text channel. For example passing the string "CHT(1,1) := 'test'" as a parameter to the CmdExecuteSync method will set the 1st row of the 1st channel to "test". Please refer to the DIAdem help for more documentation on the CHT function.
    I hope this helps! Please post back if I wasn't clear enough in explaining how to do this or if you have any problems getting it to work.
    Regards,
    Sarah Miracle
    National Instruments

  • How can i send file over messages in Mac OS X?

    Hi,
    Unable to send files from messages application in my Mac, i configured gmail account in messages so u can able to chat with my friends but i can't send any file to my friends. so is there any setting needs to be configure in preferences? please suggest me.
    Thanks in Advance,
    Suresh Balakrishnan.

    HI,
    In iChat 6 before you upgraded to Messages Beta were you able to Send Files ?
    There are also various ways to start this
    Try:-
    Dropping a file on a Buddy's name in the Buddy List
    Dragging a File to the text entry field in a chat.
    In a Video Chat drag a file over the Chat window and chose the half that says  Send File.
    As it is Google are you Buddies logged in via the Web Browser or a Jabber App or iChat on a Mac ?
    9:16 PM      Wednesday; March 28, 2012
    Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"
      iMac 2.5Ghz 5i 2011 (Lion 10.7.3)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
    "Limit the Logs to the Bits above Binary Images."  No, Seriously

  • Sending images over network socket

    I'm working on a java web server. So far i have managed to get it to send html documents sucessfully to the client web browser, using a BufferedReader, and a PrintWriter object.
    But how should i send images over the socket? using this method doesn't work. Any suggestions?
    Thanks in advance.
    hornetau

    I did it first. You may pay me $10 and get XM2 WebServer 1.2 from my company.
    Ok, I'll help ya out here...
    HTTP protocol in Internet Explorer is "juiced up" meaning that it does not require HTTP data to be correctly sent. To send an image to be deisplayed...
    <html>
    <img src="theImage.gif"></img>
    </html>
    Now, the server will see a GET request like this...
    GET /theImage.gif HTTP/1.1
    Accepts: Image/jpeg, Image/gif, ...
    Your web server (in the IE case just needs to send)...
    output.println(data);
    The data object is a string, that represents the contents of the image.
    To do that, just get the correct File object, connect reader to it, then loop it
    until the reader is no longer ready (reader.ready() != true), as it loops, just append
    the readLine() command to the end of the data string and it will be ok.
    Now this works on IE just fine, using vary small file sizes due to it being loaded directly into
    memory. Casing problem if your app has only 500K of memory and the file size is 700K, 500-700=-200K, so use only small file sizes with this method.
    There is also the URLConnection and HttpURLConnection classes to use that will do this better, but
    they dont have any real way of getting the file's data - that's still YOUR job.

  • Send email over tls protocol

    Hi
    i try to send email from my organization email server,
    i get this error: relay access denied
    and my server administrator tell me: first log in to server
    my email server port is 587.
    <big style="margin:0px;padding:0px;border:0px;color:#111111;font-family:'Segoe UI', Arial, sans-serif;line-height:normal;">how i can send email over tls protocol in vb.net or c#?</big>
    check tls out:
    Checking [email protected]
    looking up MX hosts on domain "irimo.ir"
    mail.irimo.ir (preference:10)
    Trying TLS on mail.irimo.ir[185.14.80.133] (10):
    seconds test stage and result
    [000.255] Connected to server
    [001.148] <-- 220 mail.irimo.ir ESMTP Postfix
    [001.148] We are allowed to connect
    [001.148] --> EHLO checktls.com
    [001.391] <-- 250-mail.irimo.ir
    250-PIPELINING
    250-SIZE 15728640
    250-VRFY
    250-ETRN
    250-STARTTLS
    250-ENHANCEDSTATUSCODES
    250-8BITMIME
    250 DSN
    [001.391] We can use this server
    [001.392] TLS is an option on this server
    [001.392] --> STARTTLS
    [001.626] <-- 220 2.0.0 Ready to start TLS
    [001.626] STARTTLS command works on this server
    [002.131] Cipher in use: DHE-RSA-AES256-SHA
    [002.131] Connection converted to SSL
    [002.181]
    Certificate 1 of 3 in chain:
    subject= /C=IR/ST=TH/O=Touca Collaboration Suite/OU=Touca Collaboration Suite/CN=mail.irimo.ir
    issuer= /C=IR/ST=TH/L=TH/O=Touca Collaboration Suite/OU=Touca Collaboration Suite/CN=mail.irimo.ir 
    [002.229]
    Certificate 2 of 3 in chain:
    subject= /C=IR/ST=TH/O=Touca Collaboration Suite/OU=Touca Collaboration Suite/CN=mail.irimo.ir
    issuer= /C=IR/ST=TH/L=TH/O=Touca Collaboration Suite/OU=Touca Collaboration Suite/CN=mail.irimo.ir 
    [002.277]
    Certificate 3 of 3 in chain:
    subject= /C=IR/ST=TH/O=Touca Collaboration Suite/OU=Touca Collaboration Suite/CN=mail.irimo.ir
    issuer= /C=IR/ST=TH/L=TH/O=Touca Collaboration Suite/OU=Touca Collaboration Suite/CN=mail.irimo.ir 
    [002.278] Cert NOT VALIDATED: unable to get local issuer certificate
    [002.278] this may help: What Is An Intermediate Certificate
    [002.278] So email is encrypted but the domain is not verified
    [002.279] Cert Hostname VERIFIED (mail.irimo.ir = mail.irimo.ir)
    [002.279] ~~> EHLO checktls.com
    [002.662] <~~ 250-mail.irimo.ir
    250-PIPELINING
    250-SIZE 15728640
    250-VRFY
    250-ETRN
    250-AUTH PLAIN LOGIN
    250-AUTH=PLAIN LOGIN
    250-ENHANCEDSTATUSCODES
    250-8BITMIME
    250 DSN
    [002.662] TLS successfully started on this server
    [002.662] ~~> MAIL FROM:<[email protected]>
    [004.496] <~~ 250 2.1.0 Ok
    [004.496] Sender is OK
    [004.497] ~~> RCPT TO:<[email protected]>
    [006.386] <~~ 250 2.1.5 Ok
    [006.387] Recipient OK, E-mail address proofed
    [006.387] ~~> QUIT
    [006.713] <~~ 221 2.0.0 Bye
    Unfortunately, I can not speak English well I am a beginner programmer. I love the improvements

    I don't know if this will help you but it's an email sending app I use with a gmail account. Maybe the code in it will be helpful. You can download the project, created in Visual Studio 2012 and compiled to .Net 4.0 framework I believe, from the below link.
    https://onedrive.live.com/redir?resid=B8AB225FA76F270D!187&authkey=!ALPKwhQCnN63TW4&ithint=file%2czip
    Image of app.
    La vida loca

  • How do i send an array of clusters with variable size over TCP/IP?

    Hi,
            I'm trying to send an array of clusters with varible size over TCP/IP,. But I'm facing the following problems:
    1) I need to accept the size of array data from the user and increase the size dynamically.
    I'm doing this using the property node but how do I convey the new size to my TCP read?
    2) I need to wire an input to my 'bytes to read' of the TCP read.
    But the number of bytes to read changes dynamically
    How do I ensure  the correct number of bytes are read and reflected on the client side?
    3) Is there anyway I can use global varibles over a network such that their values are updated just as if they would on one computer?
     Will be a great help if someone posts a solution!
    Thank you...

    twilightfan wrote:
    Altenbach,
     ... xml string. ...number of columns that I'm varying using property node s... I solved these problems by using a local variable as the type input ...o TCP read is creating a problem.... second TCP read gets truncated data because
    its no longer just the first four bytes that specify the length of the data, it could be more as my array of cluster can be pretty huge.
    Instead of writing long and complicated sentences that make little sense, why don't you simply show us your code? 
    What does any of this have to do with xml strings???? I don't see how using a local variable as type input changes anything. The user cannot interact with "property nodes", just with controls. Please clarify. Once the array of clusters is flattened to a string you only have one size that describes the size of the data, no matter how huge it is (as long as it is within the limits of I32). Similarly, you read the string of that same defined length and form the array of clusters from it. How big are the strings? What is your definition of "huge"?
    Here's is my earlier code, but now dealing with an array of clusters. Not much of a change. Since you have columns, you want 2D. Add as many diensions you want, but make sure that the control, diagram constant, and indicator all match.
    The snipped shows for a 1D array, while the attached VI shows the same for a 2D array. Same difference.  
    Message Edited by altenbach on 01-31-2010 01:13 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    FlattenArrayOfClusters.vi ‏12 KB
    ioclusters3MOD.png ‏25 KB

  • Send multiple strings over TCP - Like messenger service

    Hello all Java Coders,
    I'm new with TCP programming.
    I'm beggining to learn about TCP and sockets connections in Java. In order to achieve this, I was coding a mini-program so I can learn a little bit about this.
    I'm trying to make a simple TCP program.
    The server sends a string to a client...
    I already searched for a couple of hours in google and so on, about what I'm doing wrong.
    [The server code (Just click)|http://pastebin.com/m39fd1273]
    [The client code (Just click)|http://pastebin.com/m57471803]
    I hope that someone can help me with this and, if you have patience, please tell me the reasons my code doesn't work.
    Many thanks,
    Freiheitpt
    P.S.: I think that the problem is on the server side...

    Sorry jverd.
    I was just trying to put things organized.
    Well, I can't get the String to be sent to the client.
    No error occurs.
    Server:
           try {
                srvr = new ServerSocket(1234);
                System.out.println("Connecting...");
                skt = srvr.accept();
                System.out.println("Connected!\nPreparing data exchange...");
                stream = skt.getOutputStream();
                out = new PrintWriter(stream, true);
                System.out.println("Done!\nReady to Send!");
            } catch (IOException ex) {
                System.out.println("Ups, didn't work!");
                System.exit(1);
            while(!data.equalsIgnoreCase("end")) {
                System.out.print("String to send: ");
                data = input.nextLine();
                System.out.print("Sending string: '" + data + "'\n");
                out.print(data);
            }Client:
            try {
                skt = new Socket("localhost", 1234);
                System.out.println("Connecting...");
                if (skt.isConnected()) {
                    System.out.println("Connected!\nPreparing data exchange...");
                    stream = skt.getInputStream();
                    inputStream = new InputStreamReader(stream);
                    in = new BufferedReader(inputStream);
                    System.out.println("Done!\nReady to Receive!");
                } else {
                    System.out.println("Server not available!\nExiting...");
                    skt.close();
                    System.exit(1);
            } catch (IOException ex) {
                System.out.println("Ups, didn't work!");
                System.exit(1);
            while (!data.equalsIgnoreCase("end")) {
                while(!in.ready()) {}
                data = in.readLine();
                System.out.println("Received String: '" + data + "'");
            }

  • Can I render a Flash frame as a bitmap and send it over TCP/IP?

    I want to draw some combination of bitmaps, flash shapes, vectors, text etc and draw them programmatically into my movie using ActionScript, and then get every "rendered" pixel of my movie (at 100% view) into an array that I send to another program over TCP/IP. Can anyone help me here?
    The first part of the question is if its possible to render a frame that is a collection of Flash elements as a bitmap? I know that I can iterate through a bitmap and get every pixel using the getPixel method but I'm trying to access the final rendered frame displayed on my screen, including, as I said Flash shapes and text.
    The second question is what would be the best way to send this "video frame" over TCP/IP? Would I use an XML socket connection? That is the only way I know how to send data out of Flash over TCP/IP but I don't know if it is the only way - the help page says the data needs to be formatted as XML, which seems unwieldly for this application.
    I'm doing this now by using Max/MSP/Jitter to do a screen capture the size and location of my Flash movie and then send out the resulting matrix using a "jit.net.send" object (which lets you send frames of video over TCP/IP), but this is too clumsy for the installation I am building.
    Any help would be greatly appreciated!
    -bob

    Thanks! That was exactly what I was looking for in the first half of the question. And I guess the draw() method works in AS2 as well as AS3. I will test it but from what I understand, I can use a Bitmap as kind of my bottom-level container, then create (in ActionScript) a movie clip that can contain other movie clips or drawing API commands or whatever, animate these various elements then finally draw() them into the bitmap. I see that in AS3 I can even use getPixels or getVector to capture the full "video frame" in one line of code.
    Thanks rothrock, for the helpful links. My application is kind of unusual, in that I'm sending "video" data to a proprietary LED controller box for display on a low resolution LED display. I connect to the box over TCP/IP and send it "frames of video" 20 times a second. I got this to work with this other content and software (Max/MSP/Jitter) and I want to see how I could capture all the rendered pixel data in successive frames of Flash animation, format it properly, then send it over TCP/IP to this controller box. Don't really now enough about the various flavors of TCP/IP connections to figure out how to do this in Flash, and I know there are security limitations built in to Flash that have to be worked around. But my movies are small (say 96 pixels by 72 pixels) and I need to send uncompressed data directly to my controller box, so these interesting links showing how to use server-side scripts to create jpgs or pngs are probably not going to help me. I will hopefully find a higher-level programmer than myself to work this out, and I think some of the techniques here will hopefull prove to be helpful.
    Thanks again for your help!

  • How to send string data through socket!

    Is there any method to send string data over socket.
    and if client send string data to server,
    How to get that data in server?
    Comments please!

    Thank for your kind answer, stoopidboi.
    I solved the ploblem. ^^;
    I open the source code ^^; wow~~~~~!
    It will useful to many people. I spend almost 3 days to solve this problem.
    The program works like this.
    Client side // string data ------------------------> Server side // saving file
    To
    < Server Side >
    * Server.java
    * Auther : [email protected]
    import java.io.*;
    import java.net.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Server extends JFrame
         private JTextField enter;
         private JTextArea display;
         ObjectInputStream input;
         DataOutputStream output;
         FileOutputStream resultFile;
         DataInputStream inputd;
         public Server(){
              super("Server");
              Container c = getContentPane();
              enter = new JTextField();
              enter.setEnabled(false);
              enter.addActionListener(
                   new ActionListener(){
                        public void actionPerformed(ActionEvent ev){
                             //None
              c.add(enter, BorderLayout.NORTH);
              display = new JTextArea();
              c.add(new JScrollPane(display),
                     BorderLayout.CENTER);
              setSize(300, 150);
              show();
         public void runServer(){
              ServerSocket server;
              Socket connection;
              int counter = 1;
              display.setText("");
              try{
                   server = new ServerSocket(8800, 100);
                   while(true){
                        display.append("Waiting for connection\n");
                        connection = server.accept();
                        display.append( counter + " connection is ok.\n");
                        display.append("Connection " + counter +
                             "received from: " + connection.getInetAddress().getHostName());
                        resultFile = new FileOutputStream("hi.txt");
                        output = new DataOutputStream(resultFile);
                        output.flush();
                        inputd = new DataInputStream(
                             connection.getInputStream()
                        display.append("\nGod I/O stream, I/O is opened\n");
                        enter.setEnabled(true);
                        try{
                             while(true){
                                  output.write(inputd.readByte());
                        catch(NullPointerException e){
                             display.append("Null pointer Exception");
                        catch(IOException e){
                             display.append("\nIOException Occured!");
                        if(resultFile != null){
                             resultFile.flush();
                             resultFile.close();
                        display.append("\nUser Terminate connection");
                        enter.setEnabled(false);
                        resultFile.close();
                        inputd.close();
                        output.close();
                        connection.close();
                        ++counter;
              catch(EOFException eof){
                   System.out.println("Client Terminate Connection");
              catch(IOException io){
                   io.printStackTrace();
              display.append("File is created!");
         public static void main(String[] args){
              Server app = new Server();
              app.addWindowListener(
                   new WindowAdapter(){
                        public void windowClosing(WindowEvent e){
                             System.exit(0);
              app.runServer();
    < Client side >
    * Client.java
    * Auther : [email protected]
    package Client;
    import java.io.*;
    import java.net.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Client extends JFrame
         private JTextField enter;
         private JTextArea display;
         DataOutputStream output;
         String message = "";
         public Client(){
              super("Client");
              Container c = getContentPane();
              enter = new JTextField();
              enter.setEnabled(false);
              enter.addActionListener(
                   new ActionListener(){
                        public void actionPerformed(ActionEvent e){
                             //None
              c.add(enter, BorderLayout.NORTH);
              display = new JTextArea();
              c.add(new JScrollPane(display), BorderLayout.CENTER);
              message = message + "TT0102LO12312OB23423PO2323123423423423423" +
                        "MO234234LS2423346234LM2342341234ME23423423RQ12313123213" +
                        "SR234234234234IU234234234234OR12312312WQ123123123XD1231232" +
                   "Addednewlinehere\nwowowowwoww";
              setSize(300, 150);
              show();
         public void runClient(){
              Socket client;
              try{
                   display.setText("Attemption Connection...\n");
                   client = new Socket(InetAddress.getByName("127.0.0.1"), 8800);
                   display.append("Connected to : = " +
                          client.getInetAddress().getHostName());
                   output = new DataOutputStream(
                        client.getOutputStream()
                   output.flush();
                   display.append("\nGot I/O Stream, Stream is opened!\n");
                   enter.setEnabled(true);
                   try{
                        output.writeBytes(message);
                   catch(IOException ev){
                        display.append("\nIOException occured!\n");
                   if(output != null) output.flush();
                   display.append("Closing connection.\n");
                   output.close();
                   client.close();
              catch(IOException ioe){
                   ioe.printStackTrace();
         public static void main(String[] args){
              Client app = new Client();
              app.addWindowListener(
                   new WindowAdapter(){
                        public void windowClosing(WindowEvent e){
                             System.exit(0);
              app.runClient();

  • Not Sure How To Send String

    I'm totally new to trying to network using Java and extremely poor at networking in general so bear with me here.
    I'm trying to make a top down shooter and currently the application allows the user to either play as host or connect to a host but all the network communication handling I'm doing involves creating strings, sending them along the connection and interpreting the strings on their reciept.
    The problem I'm having is I keep getting an unexpected end of file exception when it tries to read in the string.
    I used a basic IM application as an example of how to connect and send info in Java, which is where I got the idea to use in.readUTF and out.writeUTF to send string information but upon looking into this problem it seems to me that read/writeUTF is not really designed for strings and there should be something else I should use instead but I'm not sure what?
    Also I'm using this to communicate point information of each player and as I understand it I should be using TCP to do this as that was what the example I'm using said it used. Though I think it might be more useful to use UDP as it's faster and it shouldn't matter if I drop a packet or two, though I'm not sure where in my code it specifies a difference between the two and if that really is the best idea.
    Here's a zip of my netbeans project, though be warned it's VERY messy, probably the messiest code I've ever written, not to mention hacky as well: http://rapidshare.com/files/369943023/KerazehDood.zip
    Any help would be great.
    Thanks.
    Edited by: ThePermster on Mar 30, 2010 6:59 AM

    Thanks that seems to make much more sense, still having some troubles though.
    Ok so now the majority of it seems to be working and it seems to be sending the String just fine. And I'm having it send the String to the BufferedWriter "out" and then using the newLine() method to send a carriage return but the BufferedReader on "in" seems to not detect the carriage return.
    I have it doing a readLine() so that (as I understand it) it should be blocking, waiting until an end of line character so I assume each call of newLine() should have it pick up something but a quick breakpoint shows that it never stops blocking on readLine().
    I assume the connection is fine because the application running as server uses the socket object returned by the accept() method.
    Is there something I've perhaps misunderstood about the BufferedReader's readLine() method?
    Here's the new version of my netbeans project:
    http://rapidshare.com/files/371224512/KerazehDood.rar
    Also on a different line of questioning, I'm just wondering about socket convention.
    I was thinking it'd be useful in a game similar to what I'm attempting to make to not only send player position information but also client keypress information, I was just wondering, if you're doing something like that would it be frowned upon to use two separate ports? I think it would make the implementation far more legible and easy to structure but wasn't sure if applications usually try to stick to only one port or not.
    Thanks.
    Edited by: ThePermster on Apr 2, 2010 10:54 AM

  • How do I send an Image over a socket ?

    I'm trying to get the output from my webcam and send that data out to a socket. Now the output from the webcam is running I'm just not sure how to send it out over the socket.
    Server.java
    import java.io.*;
    import java.net.*;
    public class Server {
       public static void main(String args[]) {
         ServerSocket serverSocket = null;
         boolean listening = true;
         try {
         serverSocket = new ServerSocket(1354);
         System.out.println("Listening for Connections...");
         } catch (IOException drr) {
         System.out.println("Error Listening :" + drr);
         System.exit(-1);
         try {
         while(listening)
         new ServerThread(serverSocket.accept()).start();
         } catch (IOException er) {
         System.out.println("Error Creating connection:" + er);
         try {
           serverSocket.close();
         } catch (IOException err) {
         System.out.println("Error Closing:" + err);
    }When a connection is made it will start the webcam and send the image.
    ServerThread.java
    import java.net.*;
    import java.io.*;
    import java.awt.*;
    import java.awt.image.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.io.*;
    import javax.media.*;
    import javax.media.format.*;
    import javax.media.util.*;
    import javax.media.control.*;
    import javax.media.protocol.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.image.*;
    import java.awt.event.*;
    import com.sun.image.codec.jpeg.*;
    public class ServerThread extends Thread {
        public static Player player = null;
        public CaptureDeviceInfo di = null;
        public MediaLocator ml = null;
        public JButton capture = null;
        public Buffer buf = null;
        public Image img = null;
        public VideoFormat vf = null;
        public BufferToImage btoi = null;
        public ImagePanel imgpanel = null;
        private Socket socket = null;
        Image blah;
        PrintWriter out = null;
        public ServerThread(Socket socket) {
         super("ServerThread");
         this.socket = socket;
        public void run() {
         try {
             out = new PrintWriter(socket.getOutputStream(), true);        
             imgpanel = new ImagePanel();
                 String str1 = "vfw:CompUSA PC Camera:0";
                 String str2 = "vfw:Microsoft WDM Image Capture (Win32):0";
                 di = CaptureDeviceManager.getDevice(str2);
             ml = new MediaLocator("vfw://0");
                try {
               player = Manager.createRealizedPlayer(ml);
                 } catch (Exception npe) {
               System.out.println("Player Exception:" + npe);
                player.start();
             Component comp;
             if ((comp = player.getVisualComponent()) != null) {
               // Grab a frame
               FrameGrabbingControl fgc = (FrameGrabbingControl) player.getControl("javax.media.control.FrameGrabbingControl");
               buf = fgc.grabFrame();
               btoi = new BufferToImage((VideoFormat) buf.getFormat());
               //Send the image over the socket
               out.println(btoi);
         } catch (IOException e) {
             System.out.println("It bombed:" + e);
        public static void playerclose() {
           player.close();
           player.deallocate();
      class ImagePanel extends Panel {
        public Image myimg = null;
        public ImagePanel() {
        public void setImage(Image img) {
          this.myimg = img;
          repaint();
        public void paint(Graphics g) {
          if (myimg != null) {
            g.drawImage(myimg, 0, 0, this);
      }The output I get from running the server is this:
    BufferedImage@c9131c: type = 1 DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0 IntegerInterleavedRaster: width = 320 height = 240 #Bands = 3 xOff = 0 yOff = 0 dataOffset[0] 0
    Now how can I turn this into an image If this output is correct?

    HUH?
    I got the one to send the images over the network. I'm now trying to get the exact feed of the webcam and sending that over the network. This is alot more difficult to accomplish but I did see where I messed up my process of sending the images was just having to save the file then open it up put it in a byte array then send that over the network to the client. Once it was at the client i was able to re-construct it and throw it up in the frame. The only problem was lag. So this tells me it would be much more faster if instead of saving the file to send the client and having to reconstruct the image I should just send the webcam feed i used to make the image.
    eh, I guess I didn't need any help.
    Hey no offense or anything but you really have to learn how to spell better.

  • How can I send multiple string commands into a VISA write?

    Hi Fellow LabVIEW users
    I am very new to LabVIEW (2.5 months) so please forgive me if my lingo is not up to par.
    How can I send multiple string commands to a VISA write. For example each string command looks like this
    1) 3A00 0000 0000 FFFF FFFF FFFF 0000 0000 FF00 0000 0000 0000 0000 0033 (Scenario 1)
    2) 3A01 0000 0000 FFFF FFFF FFFF 0000 0000 FF00 0000 0000 0000 0000 0034 (Scenario 2)
    3) 3A01 0000 0000 33FF FFFF FFFF 0000 0000 FF00 0000 0000 0000 0000 0067 (Scenario 3).
    and so on and so forth. And there are a number of scenarios.
    Each String scenario will give a different string output which will be interpreted differently in the front panel.
    Right now I have to manually change the string commands on the front panel to give me the desired output. How can I do this without manually changing the commands i.e. hard coding each scenario into the block diagram?
    Thanks, any feedback will help.
    mhaque

    Please stick to your original post.

  • Get error 66, when try to use TCP vi send string to arduino

    I use TCP vi to send string to arduinos (arduino uno+ arduino wifi shield, and they have arduino code preloaded inside ) wirelessly through the router. Sometimes they can communicate well, the arduino receive the string send by the TCP vi. But sometimes, there will be an error 66 come out of TCP Write vi, so, labview loop will stop. Arduino will say "connection failed". And I have config the VI sever allow the arduino to access.
    Another thing I want to mention is, when I highlight the execution, the error will come out more frequently.

    Actually, they can communicate not only once, sometimes the VI can pass data several rounds, but suddenly the error 66 appears in TCP write, the loop will stop. And if I rerun the program, things happens again. can anybody tell me why the error come out? Thanks

Maybe you are looking for

  • XML: How to convert xml string into Node/Document

    I have a string in xml form. <name> <first/> <second/> </name> I want to convert this string into DOM Node or Document. How can I do this? Any help or pointer? TIA Sachin

  • Multiple Calenders on Mobile devices

    Hi, In GroupWise I have my main calendar and then there are additional calendars as well. (Whether created or shared) When I sync my mail account to my phone, only the main calendar syncs across and not the others. Is this a limitation or is there a

  • HT2929 record live set with garageband

    hi, is it possible to record a liveset with garageband through my mac connected to my mixer ? rgds  niels

  • Slow LAN connections MacPro(new) + Mavericks

    Hmm.. We run IPv6 here among all machines in addition to IPv4. Mavericks preferentially runs most services over v6 if you have it and Bonjour goes for a v6 address too when connecting. New MacPro to old MacPro (2011), MacBookPro etc. Mavericks on all

  • Atmelwlandriver?

    Has anyone used the atmelwlandriver with pcmcia-cs?  I only started using Arch today so maybe I'm doing something silly.  My card's a Belkin F5D6020v2, and I followed basically the same steps which worked under Gentoo. I installed pcmcia-cs from abs