Need a lot of help with networking

How would you make a program that would send a message to another person? Im fairly new a networking in java, and i cant seem to get the tutorials to work. Can anyone out there help me?

import java.io.PrintWriter;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
public class TCPEchoServer
   private static ServerSocket servSock;
   private static final int PORT = 1234;
   public static void main(String[] args)
      System.out.println("Opening port...\n");
      try
         servSock = new ServerSocket(PORT);      //Step 1.
      catch(IOException e)
         System.out.println("Unable to attach to port!");
         System.exit(1);
      do
         run();
      }while (true);
   private static void run()
      Socket link = null;                        //Step 2.
      try
         link = servSock.accept();               //Step 2.
         BufferedReader in =
              new BufferedReader(
                    new InputStreamReader(
                        link.getInputStream())); //Step 3.
         PrintWriter out = new PrintWriter(
                   link.getOutputStream(),true); //Step 3.
         int numMessages = 0;
         String message = in.readLine();         //Step 4.
         while (!message.equals("***CLOSE***"))
            System.out.println("Message received." +message);
            numMessages++;
            out.println("Message " + numMessages
                          + ": " + message);     //Step 4.
            message = in.readLine();
         out.println(numMessages
                         + " messages received.");     //Step 4.
          catch(IOException e)
               e.printStackTrace();
          finally
               try
                    System.out.println(
                                        "\n* Closing connection... *");
                    link.close();                        //Step 5.
               catch(IOException e)
                    System.out.println("Unable to disconnect!");
                    System.exit(1);
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.UnknownHostException;
import java.net.Socket;
import java.net.InetAddress;
public class TCPEchoClient
     private static InetAddress host;
     private static final int PORT = 1234;
     public static void main(String[] args)
          try
               //host = InetAddress.getByName("A1005-22");
               host = InetAddress.getLocalHost();
          catch(UnknownHostException e)
               System.out.println("Host ID not found!");
               System.exit(1);
          run();
     private static void run()
          Socket link = null;                    //Step 1.
          try
               link = new Socket(host,PORT);          //Step 1.
               BufferedReader in =
                    new BufferedReader
                         (new InputStreamReader
                                 (link.getInputStream()));//Step 2.
               PrintWriter out = new PrintWriter(
                         link.getOutputStream(),true);      //Step 2.
               //Set up stream for keyboard entry...
               BufferedReader userEntry =
                         new BufferedReader
                               (new InputStreamReader(System.in));
               String message, response;
               do
                    System.out.print("Enter message: ");
                    message =  userEntry.readLine();
                    out.println(message);           //Step 3.
                    response = in.readLine();          //Step 3.
                    System.out.println("\nSERVER> " + response);
               }while (!message.equals("***CLOSE***"));
          catch(IOException e)
               e.printStackTrace();
          finally
               try
                    System.out.println(
                                   "\n* Closing connection... *");
                    link.close();                    //Step 4.
               catch(IOException e)
                    System.out.println("Unable to disconnect!");
                    System.exit(1);
}

Similar Messages

  • Need a lot of help with Kinetic Systems 3988 LabView VIs.

    I have a Kinetic Systems 3988 CAMAC Crate Controller. I am using the KS3988 LabView 5.1 set of VIs to communicate with the device. I downloaded this set of VIs from the NI web site. I'm new to LabView, so I'm having great difficulty. Virtually all of my commands result in time outs. Has anyone made simple LabView applications using the KS3988 set of VIs? I could really use them.

    Hello,
    I was unable to find any helpful application development information on the NI website regarding the 3988 VIs, but I did a search on the Internet for "3988 LabVIEW" (without the quotes) and several webpages came up (some in German) for some companies that seemed to be using the 3988 VIs in their applications. I recommend you perform a web search for more information on resources that could help you with using these VIs.
    I hope this suggestion proves helpful. Have a pleasant day.
    Sincerely,
    Darren Nattinger
    Applications Engineer
    National Instruments
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman

  • I had downloaded a pair of albums, and i can´t see it on my iTunes library, neither in downloaded..., i had downloaded a pair of albums, and i can´t see it on my iTunes library, neither in downloaded... I need a lot of help please.

    i had downloaded a pair of albums, and i can´t see it on my iTunes library, neither in downloaded...,. I need a lot of help please

    Do the tracks show up in the Recently Added playlist? If so then something has gone wrong with the index of the Music playlist. Download the current iTunes Free Single of the Week. I know it sounds odd, but it should fix the problem. (Probably adding anything would do.)
    If that doesn't work close iTunes and delete the hidden file sentinel from inside the main iTunes folder, then start iTunes again. It should run a consistency check when it starts up.
    tt2

  • Need help with networking external hard drive

    Hi,
    I am working on a corporate network and I have a Western Digital My Book Studio Edition external hard drive attached to a Mac OSX 10.4. i have other Macs connecting through the network to this Mac and accessing the external hard drive and it works just fine for that.
    What I need help with is the fact that I also have several PCs on the same network (all XP), that need to connect to the hard drive and access the files. I've been able to connect to the Mac using the XP by accessing the IP address. I also set the Mac up with password credentials so that I had to log in to the Mac to access the files. But when I try to access the Mac, it only shows the main computer drive as the only available share and no external drive.
    Does anyone know how to access a Western Digital external drive on a Mac from a PC through a network?

    For an external hard disk drive or other (different) system shared
    storage devices to work, they probably should be formatted in a
    format seen by both operating systems.
    If the WD unit is not seen by Windows computers on your network,
    the WD may have been formatted in HFS+ for the Macintosh. That
    is OK unless you need a Windows computer to access the same.
    The Macintosh can see and use a standard Windows disc format;
    so the external drive may need to be reformatted away from HFS+
    if that is really what is going on (and archive any data on the suspect
    drive elsewhere, since it will be lost to reformatting overwrites)
    and then both Mac OS X and Windows should see the files on there.
    And Macs set up to run Windows may also see the non-Mac format;
    without having to re-boot via BootCamp, if that option is in use.
    As to the other question(s) I really have no idea at this point in time.
    And since that may be the rub, hopefully someone will follow up here.
    Good luck & happy computing!

  • I need some (make that lots of) help with buttons

    Hi,
    I am a new designer and I am working on my first web site for free. It started out as something I was capable of doing but it has now expanded into a site that is challenging for me. Anyway, I am having a lot of confusion with with making flash navigation buttons for the site.
    This is what the person wants.  In the up state he wants the button label in text only. In the over state he wants the text with a gray line behind it that slowly expands onto the page. In the down state he wants the same thing but have the text color change and the line color to change. This line is also suppose to stay on the page until the user moves the mouse again. Ultimately the line should also stay fully extended for a sub-menu.
    This is what I have done. I have been using action script 2 so I can use the behaviors panel. I made two different movie clips, one gray and one white, using shape tweens to slowly expand the lines.
    I started out with the lable only and turned it into a button. It showed in the "up" section of the time line and I put a fram in the "hit" section (layer 1).
    Next I inserted a new layer (layer 2) and put a keyframe in the over section of the timeline and made a gray box for behind the text and attached my gray movie clip to the end of it. I put layer 1 above layer 2 so that the text would show through. I did basically the same thing for layer 3 in the "down" section
    except changed the colors to black and put a keyframe in layer 1 to change the text color.
    Now this is what I get when I play the movie in flash. I have a button that the "hand" appears in only one very small section of it below the text. It does not appear when I hover over the text. When I "hit" the line keeps repeating the movie. I know this is a behavior but when I use the behavior panel to put in play and stop it shows the event as none. As for my black line in the down section, it plays so fast that it might as well not be there. How on earth do I stop it and get it to remain on the page? I also should tell you that I know very little about action script just in case that is the direction that I need to go.
    Thanks

    You'll probably have to spend some time learning how to create buttons and movieclips that do what you want, which is what you are in the thick of at the moment.  For the small area you say reacts to the mouse, the Hit frame is used to define the area that you want to be reactive... so if you had a tiny dot in the normal frames, you could add a big dot in the Hit frame to make it easier to get the mouse to work with the button... the Hit frame content does not display.
    For the movieclips, you need to add stop(); commands at the end of their timeines if you don't want them to loop.
    Another approach you might consider is to create your buttons as movieclips rather than as button symbols.  Going this route gives you much more control of how things behave, but does involve some actionscript to make them behave as if they were buttons for the various states. Some people do not use button symbols and will only use movieclip versions of them.

  • Need help with network user accounts on Mac server App on Yosemite, any tips?

    I've been trying to set up a small network with the Server app on Yosemite. I don't want to do anything crazy with the server, I'd just like to know how I can set up network user accounts so that they can login from other Mac computers on the same network. I already have Open directory set up, the Macs that will be used on the network with the server have already been joined to the server under login options. I have created the network user account, I have also joined the user account to a group that I created. When I try to login to the network account from one of the Macs, it doesn't work. I'm pretty rookie with Mac server, can anyway give me any pointers of what I should be doing? Or if I am doing something wrong. Thanks guys.

    The most important step, once you've got Open Directory and DNS set up, with Local Network Users set up in Server.app, is to make sure that all client Macs are using the server's IP address as the primary DNS server in System Preferences > Network, and that they have joined the Network server in System Preferences > Users and Groups > Login Options.
    Having said all that, I have just spent hours setting this all up only to find out that Mail doesn't currently work with Network Homes in 10.10.3 / Server.app 4.1.
    I will be hoping that Apple recognise the bug, and put out a fix soon.

  • Early 2007 Macbook...I need a lot of help and am computer illiterate

    I have an early 2007 white MacBook 13". I have used it since I started college in 2007. I know I have accumulated a lot of photos and music on it, all of which I am sure contribute to it running incredibly slow. I am horrible at navigating these boards as I do not know how to word my questions in a way that even makes sense....so here are my questions (the simpler the answers the better!) (and I apologize in advance because they have all probably been answered):
    1. What can I do to make my computer run faster? I have read about RAM but I don't even understand what RAM is...is that what I need? Would an external hard drive help at all? I have tried deleting files and saving pictures onto USB drives and then deleting them. I also have repaired the disk utilities multiple times. None of that helped. I know there are tons of posts on here about that stuff...but they are so jumbled and I get so lost as to what I've done. Obviously I have read some posts because I did the disk utility thing.
    2. What is the highest OS X update my computer can handle? I read I can't have Mountain Lion due to my computer basically being out of date... but can I install Lion? And also, can I skip an update (for example go from Leopard to Lion)?
    Again sorry for the repetition. I am hoping people on here are nice enough to just answer the questions without making me feel stupid for being repetitious. Any help would be appreciated.

    Asking questions is good, don't feel bad.
    Taking it backwards, your system cannot run 10.8 Mountain Lion.
    It can support Lion, however, the performance may or may not be great. Lion requires 2GB of memory (AKA RAM), and many have found it needs 4GB to run well. While you can install 4GB on your late 2006 MacBook, the system will only access 3GB. This article talks about upgrading from 10.5 Leopard to 10.7 Lion. Otherwise, you'll need 10.6 Snow Leopard to access the App store. If you want Lion, call the Apple online store, which in the US is 800-MY-APPLE and buy a download code, which you'll use on the App store. Lion 10.7 is $29 and Snow Leopard 10.6  is $19.99.
    Your system can easily support OS X 10.6 Snow Leopard. Call the Apple online store to order it. 10.6 requires a minimum of 1GB, and 2GB, or more, will give better performance.  OWC and Crucial are good sources for memory. This Apple note tells how to replace the memory, and this video shows you how to do that.
    Now, question 1. Two keys to speed are RAM or memory and free disk space. Discussed RAM already. Disk space the general rule is that you need 10% or more of the space free for systems usage. When you've deleted files, you've probably emptied the trash. Some have found using OnyX has helped with performance (you want the Leopard version). With any disk maintenance program, you should have a good backup before using it.
    See this FAQ on OS X performance.

  • Need help with network

    hi, i am trying to leave ubuntu, so i installed Arch Linux. it seems everything went allright on the CD installation, but i am having trouble with the network. i have a dell XPS M1330 with the intel 4965 card, and i believe that the card is recognized by the system.
    i can scan for networks, and i can even connect to my network, and when i run "iwconfig" i can see all my network details, including the password, and th signal strenth, noise, etc.
    so, everything indicates that i am succesfully connected to my network. but everytime i try a ping it fails misserably, with a host unknown. i've tried google, yahoo, msn... but it doesnt matter. they always fail.
    can anybody help me?
    btw, i've checked that hostname is the same on rc.conf and hosts

    EDIT AFTER LAST TRY!!!!!
    first of all, i have to say that even though the module is listed on rc.conf, everytime i start the computer i need to do a modprove iwl4965 for the network card to start working, then i have to do "ifconfig wlan0 up" and then is allright.
    ok, tonight is the night!!!! lets get going
    sputter wrote:But as a thought just to try and get your juices working, what happens if you enable the gateway in your rc.conf?
    how do i do that? right now my rc.conf looks like this
    gateway="default gw 192.168.0.1"
    ROUTES=(!gateway)
    sputter wrote:with wired connections at times you need to specify a broadcast address, what would happen if you ran
    "ifconfig wlan0 192.168.0.221 netmask 255.255.255.0 broadcast 192.168.0.255"
    i'll try on a few minutes,
    EDIT: nothing special, same result as before
    sputter wrote:Is your wireless module being loaded by the MODULES=() line in your rc.conf?
    yes it is, iwl4965 is listed there
    MODULES=(tg3 iwl4965 snd-mixer-oss snd-pcm-oss snd-hwdep snd-page-alloc snd-pcm snd-timer snd snd-hda-intel soundcore)
    megagram wrote:
    After doing the manual addressing using ifconfig or the manual configuration in rc.conf, can you show us the output of "route"? Just type "route" and hit enter.
    The broadcast flag is likely unneeded as a 255.255.255.0 netmask implies a 192.168.0.255 broadcast address. However, it's definitely worth a shot! I just wonder if, for some really really strange reason your router isn't using a 255.255.255.0 netmask. Can you try giving yourself a lower IP address? Try 192.168.0.2 this will guarantee that you are in the same subnet as your router.
    Try this!
    according to my wife's computer and my mint install, our netmask is really 255.255.255.0
    i will try those suggestions tonight and post the outcome here, but to begin, this is "route" on my mint install
    Tabla de rutas IP del núcleo
    Destino         Pasarela        Genmask         Indic Métric Ref    Uso Interfaz
    192.168.0.0     *               255.255.255.0   U     0      0        0 wlan0
    link-local      *               255.255.0.0     U     1000   0        0 wlan0
    default         192.168.0.1     0.0.0.0         UG    0      0        0 wlan0
    be right back
    this is the outcome on arch before doing dhcpcd
    Kernel IP Routing Table
    Destination       Gateway        Genmask         Flags Metric Ref    Use  Iface
    192.168.0.0     *               255.255.255.0   U     0      0        0 wlan0
    and this is after doing "dhcpcd wlan0" and getting again the error i posted on my last message
    Kernel IP Routing Table
    Destination       Gateway        Genmask         Flags Metric Ref    Use  Iface
    169.254.0.0     *               255.255.0.0   U     0      0        0 wlan0
    this time i was unable to get a working Access Point although i could connect to my network
    Last edited by apertotes (2008-08-06 19:10:24)

  • Need help with network adapters for presario sr2163wm

    i cant get my network adapter to work on my presario sr2163wm,can someone help find them

    Hi:
    Below is the link to the network drivers you need for your PC.
    Download the driver file for the operating system you have installed on your PC.
    http://www.realtek.com.tw/downloads/downloadsView.aspx?Langid=1&PNid=14&PFid=6&Level=5&Conn=4&DownTy...
    Paul

  • I need help with network install of SQL Developer 3.2

    All,
    Does anyone have any references on how to perform a network install for SQL Developer? Here is what I'm trying to achieve:
    1. Network installation on drive S:\ (Windows, obviously)
    2. User links to network installation
    3. Connections are unique for each user
    I found the 2006 posting of network install for Raptor, but I could not find anything that correlates with the latest release. All I have done so far is downloaded and unzipped. Any help/instructions/guides/tutorials are welcome.

    You have installed!.  The code for SQLDeveloper does not have an installer.
    If the software is on S, say a shared drive, each user will start sqldeveloper and a directory called sqldeveloper  will be created in their local %APPLICATION_DATA% folder.  This will keep all connections etc unique for all users. 
    You will have to create a link from the S drive to the sqldeveloper.exe if you want a shortcut to start it.  We dont provide it.
    Thanks
    B

  • Need help with Network Mapping

    I have a WRT350N and have upgraded the firmware to 1.03.7. I have it setup and reliable, and am now trying to hook up a Lacie 500G hard drive to the usb connection. I have created a share and now am trying to get Vista to see it. When I map a network drive, no option for the router shows up. Under Network it just shows my computer, shared files and printers. When I click on the router under Network it times out and says the connection is busy connecting and disconnecting. Are there some settings I don't know about? I have enabled everything under the sharing tab in the Linksys menu Thanks.

    try accessing the drive using start >> run >> \\router'sipadd .. if you see the drive , right click on it and click map network drive..check whether it makes any difference

  • ITunes is black, need a lot of help!

    I just downloaded the new iTunes 7.7 today. When I opened it up, the whole screen is black. Some of the words (like File, Edit, Controls...<on the top>) are in white, but everything else on the screen is black. I tried to minimize and maximize, but nothing changed. I restarted my computer..then I uninstalled and reinstalled, but still nothing. I am having problems, and I am getting so frustrated. Please, If you know anything please help. (I have looked at other sites for this problem, but still no help. I tried to go to compatibility and disbling some stuff as one site told me to, but it did not help.)

    mm3mm wrote:
    none of this will compile and i am missing a lot.Stop right now, scrap this code and restart as this line above alone tells me that your going about your coding all wrong, that you're trying to add code to already bad code. What you need to do is this:
    1) Plan first. Before committing a single line of code, write a general outline for your program and then flesh it out (all on paper).
    2) When you start writing code, do it in small bits at a time.
    3) After adding a small bit of code (a few lines) try to compile the code to see if there are any compile errors.
    4) Here's the important part: if you find any compile or run errors, then stop, do not add any more code, but instead fix the code you have. The key is that you should never add good code to bad.
    5) Then only after the code is fixed, continue with step 3) and loop this process until done.
    Best of luck.

  • Urgent Help with network access to FileOutputStream

    URGENT HELP NEEDED GUYS...I am stuck on this past 2 days. I tried several alternatives but to vain.
    I am trying to access a Folder on a user's computer which is lying in a different Domain.
    For accessing this folder, I have the following information with me.
    Domain name, PC name, folder name, windows username, windows password.
    Note: This username and password will give me rights to read + write to that folder.
    How to use these information to open a fileoutputstream ? Does the java.io package allow programs to pass a username, password , domainname, pcname and then the folder and filename to create/read/write files..
    Pls. suggest code examples. Sometime back I posted this query but didnt get an answer to my satisfaction. I have tried at my end but unsuccessful yet. Help would be appreciated.
    I am trying this on a Windows File System and Network domain
    THIS IS V. URGENT
    Thanks,

    Hi HJK,
    I am referring to the last reply of yours.
    " Hi, there are three approaches I can think of offhand:
    1) make sure the user-context under which you run the java app has the right to access the remote drive.
    2) Do the network connection in a batch or c program and call that at the start of your java app with Runtime#exec.
    3) Write some c/c++ code to open the connection and integrate that via JNI.
    Let me know what (other) solution you came up with in the end!
    Regarding the 1st.
    I am supposed to write a remote installation utility actually. There are around 200 PC(s) in a network on which I need to copy these java class files. My problem statement is such that at runtime I only have username, passwords, domain access. I am not supposed to map any drives. Its supposed to be done dynamically. No manual intervention required. :(
    How do I do the network connection in a batch mode ? Let me know that?
    If 2nd option can be done, probably I can think of action-3 at the moment I am quite blurr :(

  • Help with Network UI Element

    My application has a need for the Network UI Element. We've been able to get the element initialized however I don't know how to access the element.
    For example, I assigned an action to the NodeSelected, but when I select a node, the method is not called.
    Also, once the user changes the layout, how do I get the results so I can write them back to the xml file?
    Any help woule be appreciated. A tutorial link for the Network element would be ideal.
    Thanks.

    I've made some progress with this (it's back in scope) however now I am having a problem that with the Network element on the screen, my page "freezes" on reload.
    My setup is like this:
    wdContext
         --> DataSourceNode (1:1)
                        --> DataSource (type Resource)
    The DataSource node has a supply function named supplyDataSource. In this function I connect to the xml document and create the resource from the input stream. This works fine, the chart is displayed.
    However now when I click on a button (which displays a popup window for search) the chart updates, but my window never opens, I just get the "loading" animated icon, but no window.
    Any ideas? If there is additional information needed, please let me know.
    Thanks.

  • Help with network on an offshore dive boat

    I have a question about the network set up on our boat.
    We have a satelite communication system. It was working fine. It has a modem with a 4 port hub on it. Off the hub goes a hardline to  the wheel hou8se computer, the dive shack computer, the surveyors computer, and to the uplink port on an 8 port switch. One goes port goes to the captains state room, one to the supervisors stateroom, one to the companymans stateroom, and one to the galley. In the galley the hardwire goes into a linksys wireless router with a 4 port hub on it, then to the computer down there. The company mans room goes to an applenet wireless router.
    Everything was working right. Then there was a problem with the satelite dish wireing. I modem was changed out. that didn't fix the problem. So the wire was changed out and the new modem was left in place. Then there was an intermittant problem with the modem, so a new one was installed.
    The origonal modem was set up to supply 4 static IP addresses and 12 DHCP random addresses. The new modem supplies 50DHCP random addresses and no static addresses.
    Here is the problem. If we plug the cable from the 8 port switch into the wireless router and the computer into one of the ports of the router I get no internet access. Wireless card say they are connectec and wired computer states that it is connected. But there is no internet access. If I unplug from the router and plug directly into the PC and the repair the connection I have internet acess. We wanted to have wireless access on the top deck so we hooked a linksys wireless router directly up to a cable that runs to the modem then hooked the diveshacks computer into the router and we have the same exact problem up there.
    What could be the solution.
    Please help.
    BTW: Both routers are WRT54G

    Thanks for the sujestion. It was right on the money. I needed to contact the satelie comany and get the IP config information from then and then set up the router to use a static IP and static gateway and disable the DHCP.

Maybe you are looking for