Problem with socket programming(Vista)

I'm not sure if this has something to do with windows vista.
I wrote simple echo client and server programs and the client program contains these lines
String hostname="172.16.54.22"; //My comp's IP
int portNo=6666;
mySocket=new Socket(hostname, portNo);
Now the problem is that the client program is able to communicate with the server only when I run both of them in xp machines or if I run the server in vista and client in xp. The client is not able to connect to the server when both the client and server are running in a vista machine or if the server is running in xp and client in vista.
It'd be nice if any of you could throw some light on this issue.
PS:
It doesn't work even if I turn the firewall off
The programs work well when I give hostname="localhost" or hostname="127.0.0.1"
Here are my programs
//EchoClient.java
import java.io.*;
import java.net.*;
import java.util.*;
class EchoClient
     public static void main(String args[])
          String hostname="172.16.54.25"; //My ip address
          int portNo=6666;
          //if(args[1]
          //PrintWriter out=null;
          Socket mySocket=null;
          BufferedReader networkIn=null;
          BufferedReader userIn=null;
          PrintWriter sockOut=null;
          try
               mySocket=new Socket(hostname, portNo);
               networkIn=new BufferedReader(new InputStreamReader(mySocket.getInputStream()));
               userIn=new BufferedReader(new InputStreamReader(System.in));
               sockOut= new PrintWriter(mySocket.getOutputStream());
               System.out.println("Connected to Echo Server\n");
               System.out.println("Enter a series of lines (\"end\" to exit)\n");
               while(true)
                    String myLine=userIn.readLine();
               //     System.out.println(myLine);
                    if(myLine.equals("end"))
                         break;
                    sockOut.println(myLine);
                    sockOut.flush();
                    System.out.println(networkIn.readLine());
          catch(IOException exc)
               System.err.println(exc);
          finally
               try{
               if(networkIn!=null) networkIn.close();
               if(sockOut!=null) sockOut.close();}
               catch(IOException exc){ }
               EchoServer.java
//EchoServer.java
import java.io.*;
import java.net.*;
class EchoServer
     public static void main(String args[])
          int portNo=6666;
          ServerSocket serverSock=null;
          try
               serverSock=new ServerSocket(portNo);
               System.out.println("Echo Server Started\n\n");
               while(true)
                    Socket clientSock=serverSock.accept();
                    new Thread(new EchoServerThread(clientSock)).start();
          catch(IOException exc)
               System.err.println(exc);
     EchoServerThread.java
//EchoServerThread.java
import java.io.*;
import java.net.*;
import java.util.*;
public class EchoServerThread implements Runnable
     public Socket clientSock;
     EchoServerThread(Socket sock)
          clientSock=sock;
     public void run()
          System.out.println("\nAccepted Connection from a Client");
          try{
          BufferedReader in=new BufferedReader(new InputStreamReader(clientSock.getInputStream()));
          BufferedReader userIn=new BufferedReader(new InputStreamReader(System.in));
          PrintWriter out= new PrintWriter(clientSock.getOutputStream());
                    /*In sockIn=new In(clientSock);
          Out sockOut=new Out(clientSock);*/
          String str;
          while((str=in.readLine())!=null)
               out.println(str);
               out.flush();
          System.out.println("Closing Connection from a Client");
          out.close();
          in.close();
          catch(IOException exc)
               System.err.println(exc);
     

Sorry everyone but I'd been giving a wong IP address thinking it's my own. The problem's solved.
Thanks for the response Peter.

Similar Messages

  • Problem with socket programming-connecting to port 13

    Hi, I am learning JAVA, and we are on the subject of sockets. I am trying to make this program to connect to port 13, get the time, and print it to the console. This is my code:
    import java.io.*;
    import java.net.*;
    public class temp {
         public static final int PORT = 13;
         public static void main(String[] args) {
              Socket s = null;
              String line = null;
              try {
                   s = new Socket("localhost", PORT);
                   DataInputStream sin = new DataInputStream(s.getInputStream());
                   line = sin.readLine();
                   if (line != null) System.out.println(line);
              catch (IOException e) {System.err.println("!" + e);}
              finally {
                   try { if (s != null) s.close(); }
                   catch (IOException e2) {}
    And this is the output:
    !java.net.ConnectException: Connection refused: connect
    What should I do. I found that the problem is with the server I am connecting to and I tried connecting to dif. computers, or to stuff online, and nothing works.
    Any suggestions for me?
    Forgot: I tried this on both a windows XP and Vista
    Edited by: xpatrickerx on Mar 23, 2008 8:12 PM
    Tampering with it, I find that the error occurs on the following line:
    s = new Socket("localhost", PORT);
    Edited by: xpatrickerx on Mar 23, 2008 8:13 PM

    So I finally found how to use printStackTrace and here is what it gives when:
    1) I use my own computer:
    java.net.ConnectException: Connection refused: connect
         at java.net.PlainSocketImpl.socketConnect(Native Method)
         at java.net.PlainSocketImpl.doConnect(Unknown Source)
         at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
         at java.net.PlainSocketImpl.connect(Unknown Source)
         at java.net.SocksSocketImpl.connect(Unknown Source)
         at java.net.Socket.connect(Unknown Source)
         at java.net.Socket.connect(Unknown Source)
         at java.net.Socket.<init>(Unknown Source)
         at java.net.Socket.<init>(Unknown Source)
         at temp.main(temp.java:11)
    2) I use something else:
    java.net.ConnectException: Connection timed out: connect
         at java.net.PlainSocketImpl.socketConnect(Native Method)
         at java.net.PlainSocketImpl.doConnect(Unknown Source)
         at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
         at java.net.PlainSocketImpl.connect(Unknown Source)
         at java.net.SocksSocketImpl.connect(Unknown Source)
         at java.net.Socket.connect(Unknown Source)
         at java.net.Socket.connect(Unknown Source)
         at java.net.Socket.<init>(Unknown Source)
         at java.net.Socket.<init>(Unknown Source)
         at temp.main(temp.java:11)
    Again, thanks

  • Problem with Socket Programming

    Hi
    I have used java sockets in my program for installing a tool on different boxes.On running this server program on a linux box my client program is unable to listen to the socket on the linux box.It give a
    ConnectionRefused exception in the client program which is running on the windows box.This behaviour is pretty inconsistent though.The version of linux is redhat 7.3 and the kernel is 2.4.18-3 on au i686 (valhalla) and the java version on the
    linux ->1.4.0_01-b03,mixed mode.
    The windows box also has j2sdk1.4.0.
    Please reply urgently.

    I have used the same source to open sockets on windows and on solaris and it has worked consistenly.It is only the linux box that is inconsistent in listening to the sockets.
    On the server i have used this part to open the socket:
    public void process() throws Exception {
              SocketChannel sc = null;
              ServerSocketChannel ssc = null;
              Selector acceptSelector = null;
              try {
                   int port = Integer.parseInt(resourceBundle.getString("AUTH_PORT"));
                   System.out.println("Listening on Port:: "+port);
                   int socketTimeOut = Integer.parseInt(resourceBundle.getString("SOCKET_TIMEOUT"));
                   acceptSelector = SelectorProvider.provider().openSelector();
                   ssc = ServerSocketChannel.open();
                   ssc.configureBlocking(false);
                   InetAddress lh = InetAddress.getLocalHost();
                   InetSocketAddress isa = new InetSocketAddress(lh, port);
                   ssc.socket().bind(isa);
                   SelectionKey acceptKey = ssc.register(acceptSelector,SelectionKey.OP_ACCEPT);
                   int keysAdded = 0;
                   while ((keysAdded = acceptSelector.select()) > 0) {
                        // Someone is ready for I/O, get the ready keys
                        Set readyKeys = acceptSelector.selectedKeys();
                        Iterator i = readyKeys.iterator();
                        // Walk through the ready keys collection and process date requests.
                        while (i.hasNext()) {
                             boolean processFlag = true;
                             SelectionKey sk = (SelectionKey)i.next();
                             i.remove();
                             // The key indexes into the selector so you
                             // can retrieve the socket that's ready for I/O
                             ServerSocketChannel nextReady = (ServerSocketChannel)sk.channel();
                             // Accept the date request and send back the date string
                             sc = nextReady.accept();
                             so = sc.socket();
                             writeToLogFile ("Socket is ::"+so+"::",4);
    //                         so.setSoTimeout(socketTimeOut);
                             writeToLogFile ("Before receiveAuthReqMessage",4);
                             ois = new ObjectInputStream(so.getInputStream());
                             receiveAuthReqMessage();     // receive AuthReqMessage.xml
                             writeToLogFile ("After receiveAuthReqMessage::"+processFlag,4);
    //                         readAuthReqMessageData();     // reads the userName, password for validation
                             authenticate();                    // validates username & password of client
                             sendAuthResMessage();          // feedback to client AuthResMessage.xml
                             if(validbool)
                                  while (processFlag) {
                                       processFlag = receiveRegReqMessage();
                             else
                                  writeToLogFile ("INVALID : You are NOT a VALID user .......",0);
                             writeToLogFile ("Just before closing",4);
                             ois.close();
    //                         sc.close();
    //                         so.close();
              } catch (Exception e) {
              e.printStackTrace();
              finally {
                   os.close();
                   sc.close();
                   ssc.close();
                   acceptSelector.close();
                   so.close();
    and on the client part of the program i use this code to make the client listen to the server program:
         public boolean openAuthSocket(String machineName) {
              try{
                   int portNo = 0;
                   ResourceBundle resourceBundle = ResourceBundle.getBundle("GPSClientProperties", locale);
                        portNo = Integer.parseInt(resourceBundle.getString("AUTH_PORT"));
                   if (machineName == null) {
                        machineName = resourceBundle.getString("AUTH_MACHNAME");
                   authsocket =new Socket(machineName,portNo);
                   writeToLogFile("Authentication socket OPENED on authsocket: " +authsocket,4);
                   int socketTimeOut = Integer.parseInt(resourceBundle.getString("SOCKET_TIMEOUT"));
                   authsocket.setSoTimeout(socketTimeOut);
              }catch (Exception e){
                   writeToLogFile("The exception in open socket is "+e,0);
    e.printStackTrace();
                   return false;
              return true;

  • Problems with Safari in vista

    I'm having some problems with Safari in Vista.
    I recently wiped my hard drive, and reinstalled Windows. Anyway reinstalling programs and I've come into a problem.
    When I open Safari it gets stuck loading. It does this with any site.
    All my other browsers work fine, and even with the firewall and stuff turned off it won't work. It worked fine before, but now it just won't do anything. Not even a page won't display thing.
    It just gets stuck. Anyone know how to get it to work? Thanks.

    Is java 1.6.0.3 latest version installed?
    have you tried removing the two user folders that Safari uses to store prefs, bookmarks, history and cache in? (don't delete, just rename or move aside).
    For now, FF 3.0A is probably a better choice until later anyway. There are WebKit latest builds, but I don't know how to use or install those in Windows, but would be 10-19-2007 of the core foundation Safari uses.

  • Problem with the program symbols in quality

    Dear all,
    I am facing a problem with the program symbols.
    I have added new global fields in development, i have called those definations in text names. It is working fine.
    After transporting these  program changes in to quality these new global definations are not displaying in quality and varibles are not working.
    Please give me some suggestion.
    Thanks and advance

    Hi Chandra,
    Please check the following.....
    (1)The transport request status in se10 and see if has been successfully imported to QA..
    (2)if all the declarations or code have been collected in a Transport and not saved as temporary objects
    To confirm the same we have to compare the code in quality and development and see if they are the same
    Pls check and revert
    Regards
    Byju

  • I installed Adobe CS6 Design & Web Premium on my Mac Book Pro a few years ago but have repeatedly encountered problems with the programs freezing or not opening properly. It's a Student and Teacher Licensing version so an academic ID is required but I am

    I installed Adobe CS6 Design & Web Premium on my Mac Book Pro a few years ago but have repeatedly encountered problems with the programs freezing or not opening properly. It's a Student and Teacher Licensing version so an academic ID is required but I am no longer a student--can I still reinstall it since my academic ID may no longer be valid?

    Erin Elzo as long as the serial number has been registered under your account at http://www.adobe.com/ then you should be able to continue to utilize the software.  You can find details on how to locate your registered serial number at Find your serial number quickly - http://helpx.adobe.com/x-productkb/global/find-serial-number.html.

  • Problem with various programs freezing/not working

    I'm not sure if it's a problem with the computer itself or with the software, but perhaps someone on here can help me.
    For about a week now I've been having problems with various programs on my iMac. These programs include iTunes, Force Quit, Shut Down, Safari, Finder, and certain functions on the keyboard.
    The problems I've been having revolve around the programs freezing up when you either first try to operate them or after opening the programs and trying to click on things within the program itself.
    A good example: I haven't been able to use iTunes past the point of opening it up. Once I try to play a song, it freezes up and the rainbow wheel comes up and just keeps on spinning for eternity, or until I manually reboot the computer via the power button.
    The volume controls on the keyboard don't work at all. When I first boot up the computer, I can press a volume button and the symbol will appear on the screen, but the level won't move up or down and if you press it again after that disappears then it doesn't reappear.
    Force Quit and other applications tend to stay on the screen after you click the quit button or other end/cancel button and won't go away until iMac is rebooted manually by button on back.
    Safari gets stuck on occasion depending on which site I go to. It happened once when I went to MySpace.com, but only cos of one of the flash sites they were advertising. I went to the same site an hour later and it was fine since it was advertising something else. I have a job site I can't access because when I click on the 'jobs' link to look for a job, it gets 3/4 of the way through the upload and freezes.
    And right now I can't tell you which model I have since I can't access the 'About This Mac' info, other than to tell you it's the 20" with 320 GB with Leopard software, Mac OS X v10.5. It gets regular updates.
    So... if there's anyone who could help me, I would greatly appreciate it.
    Please note, I don't have Apple Care since I can't afford it yet, and I just bought my computer in October 2007. Thanks!

    Start with http://www.thexlab.com/faqs/multipleappsquit.html

  • HT201487 i have a problem with xcode programming app when i lunch to it it asking me to enter my password and when i enter it the program show that it is wrong but am 100% sure it's wright so please help me with this issue thanks

    i have a problem with xcode programming app when i lunch to it it asking me to enter my password and when i enter it the program show that it is wrong but am 100% sure it's wright so please help me with this issue thanks

    That's not very intuitive
    Check your mail server setup (mail>preferences>accounts>) choose your MobileMe account and select Outgoing Mail Server (SMTP) dropdown box, select Edit SMTP server list, verify that each instance of the me server has a password, if there are more than one and you only have one account then delete the one without a password.

  • I have a problem with the program Lightroom on Mac

    Hello!
    I have a problem with the program Lightroom on Mac
    Today set a new Lightroom CC 2015 through Creative Cloud but it does not run , I do not know what is the reason
    Please help resolve this issue as soon as possible , I can not continue its work
    Thank you for attention

    Hi Musik
    Take a look at this link and see if it helps:
    Lightroom doesn't launch or quits automatically after splash screen
    Pattie

  • Hello! Help me please, I have a problem with the program occurred after the upgrade to version 3. 6. 16, namely by pressing the button 'Open a new tab' nothing happens. ?

    Hello! Help me please, I have a problem with the program occurred after the upgrade to version 3. 6. 16, namely by pressing the button 'Open a new tab' nothing happens. ?

    This issue can be caused by the Ask<i></i>.com toolbar (Tools > Add-ons > Extensions)
    See:
    * [[Troubleshooting extensions and themes]]

  • Problems with audio programs after update to Maverics

    After updating to Mavericks on my Mac Mini there is problem with audio programs. I cant open iTunes at all, I click it and it disappear in a second. Also when I press play in GuitarPro 6 or in Vox player nothing happens. It just wont start playing. I really dont like this update.. and my mac is slower now. I cant downgrade my system back so this is really frustrating to me as a musician.

    I have the same problem with my Conceptronic CH3HNAS and have found a free and easy solution.
    Since a lot of people report they are able to access their NAS using apps other than the Finder itself, I decided to look for a free Lion-compatible File Manager to use instead of Finder.
    I have found muCommander ( http://www.mucommander.com/ ) and indeed it works fine. All I did was click on the button highlighted bellow, go to "bonjour services" and select my NAS. It prompted me for my username and password and voilá, it works fine.
    I keep Finder for everyday use and just load muCommander when I want to access the NAS. At least now I don't have to start my WinXP VM anymore just to access it.
    Hope it helps you.

  • Is anyone having problems with the program MacKeeper not runing a full scan in Mavericks?

    Is anyone having problems with the program MacKeeper not runing a full scan in Mavericks?

    Do not install MacKeeper (and how to uninstall it if you have):
    https://discussions.apple.com/docs/DOC-6221
    by Klaus1
    (Please note that references to the original developers, Zeobit, also now refer to Kromtech Alliance Corp, who acquired MacKeeper and PCKeeper from ZeoBit LLC in early 2013.
    And Here  >  Beware MacKeeper
    In General 3rd Party AV Software is Not Required as Mac OS X tends to look after itself.
    Read Here  > https://discussions.apple.com/thread/4545776?tstart=0
    See Here  >  Antivirus Discussion

  • I can not upgrade to quicktime 7.7.3 for windows vista.  Error message says there is a problem with the program installer.  Any clue as to how to get around this.

    I can not download quicktime 7.7.3 for windows vista.  The error message says that there is a problem with the windows installer.  Any clues?

    The error message says that there is a problem with the windows installer.
    What's the precise text of the message, please? (There's a few different ones I can think of that you might be getting.)

  • Problems with flash in vista - Not IE RELATED

    Just got a new laptop yesterday with:
    vista home premium 32 bit
    amd 64x2
    1g ram
    I like to play poker (just play money) on carbon poker and
    poker.com
    I installed the programs and went to play on them. The
    program loads fine, functions fine in the menus and game lists.
    But when I join a game (i.e. there are moving symbols-cards,
    chips, chat bubbles) the game window freezes within 5-10 secs,
    basically as soon as something on the table moves.
    At this point none of the buttons in the table window work.
    However, I can go into the lobby (no moving symbols) and exit the
    program.
    After exiting the program I get an error stating:
    "this program requires a missing windows component" blah blah
    the details state:
    "this program requires flash.ocx, which is no longer included
    with this version of windows"
    The solution tells me to install the latest version of flash,
    which I did.
    Same problem.
    I have tried uninstalling flash and installing full version
    (separate file, not browser based install) - no luck
    I have tried installing flash 7 and 8 - no luck
    I have tried copying flash9.ocx and renaming it flash.ocx -
    no luck
    I have tried setting program to run compatible with win xp
    sp2 - no luck
    I have searched every forum, google search string, adobe, and
    ms sites - no luck
    I have tried installing a version of carbon poker from vista
    downloads - no luck
    As far as I can tell, this program needs flash to function
    properly in the games. I don't know if there is a problem with
    where vista puts flash and the program is looking elsewhere for it
    or what.
    Can someone please help me figure out how to get these
    programs to run? They are not browser based, they are separate
    programs run from an exe.
    Thanks in advance.

    Tech support told me the problem could be caused by flash
    unexpectedly terminating. Is there any way to prevent this from
    happening? The laptop is a Compaq and came with shloads of garbage
    software on it that could be causing the complications. Any
    suggestions on where to start? Thanks in advance.

  • Problem with standby and Vista

    Hi!
    I've a problem with my X61 with the Turbo Memory and Vista x64: When I install the driver for Turbo Memory, I cannot resume from standby. The notebook does only a "normal" reboot.
    Can anybody help me with this problem?
    scw

    well after a lengthy talk with many microsoft reps i found something. I was an updated version of this "WUDfrd.sys" file. But the problem was that i could not see a download link. but after a little while i convinced microsoft to give it to me. at first it looked like it had potential but after i restarted, every went down the plug hole. here is the link that i was talking about.
    http://support.microsoft.com/kb/933607/en-us
    problem still not solved and not looking to be solved for a long time by the looks of things.... NOT HAPPY JAN!!!

Maybe you are looking for

  • Data requests in planning cube

    Hi Friends, I like to find out from you how can I delete from the cube data I loaded into a planning cube via planning activities given that the cube only creates new request after n thousand records have filled the request. In short, how can I manag

  • Acrobat X and OCR Accuracy Issues

    Does anyone know if you can assign a custom dictionary to the OCR process? I have thousands of scanned pages in PDF format that I need to OCR. When I OCR the same PDFs using another product, I get much better results. Acrobat does not see the same wo

  • How to capture workitem number

    Hi Experts, We have custom workflow for creating material master. The main workflow contains different sub workflows and tasks. The workflow has 4 levels approvals and it has been triggering from Z transaction using event. We have the requirement for

  • Which background process involves in datapump export/import?

    Hi guys, Could any one please tell me which background process involves in datapump export and import activity? . any information please. /mR

  • Safari has been deleted

    Now, first of all I want to make it perfectly clear that I didn't do this. My friend did this. She deleted Safari. Yes, it's completely deleted. What do we do to get Safari back on her macbook pro? It's a little too big to send as an email attachment