Results 1 to 6 of 6

Thread: Socket problem in java

  1. #1
    Join Date
    Dec 2009
    Posts
    292

    Socket problem in java

    Hello,
    I have a problem with my java program simple yet all I read every tutorial on the socket and yet nothing I can not solve my problem. My program has yet to connect a fixed ip as the website. I come carefree connect to google youtube etc. The concern comes when I try to connect to a computer located to router and provided with a dynamic ip address. I think I am have a socket problem in my code.
    Here is my code:
    Code:
    public class securiter {
     
    		
    	Public static void hand(String[] args) {
    	
                             Socket msoc = null ;
     
    		try {
    			msoc = new Socket("192.18.132.XX",8887) ;
                                          msoc.close() ;
    		} catch (Exception e) {
    			System.out.print("Unable to connect to the IP address") ;
    		}
    		
    	}
     
    }

  2. #2
    Join Date
    Nov 2009
    Posts
    343

    Re: Socket problem in java

    Hello,
    You have posted the client code, if you need the server code, then here it is
    Code:
    Public class securiter {
    	
    	Public static void hand(String[] args) {
    		Socket msoc = null ;
    ServerSocket msersoc = null ;
    		try {
    			msersoc = new ServerSocket(8887) ;
    msoc = msersoc.accept() ;
    msersoc.close() ;
    msoc.close() ;
    		} catch (Exception e) {
    			System.out.print("Can not open up the port 8887") ;
    		}
    		
    	}
     
    }

  3. #3
    Join Date
    Dec 2009
    Posts
    192

    Re: Socket problem in java

    Hello,
    Even I am having a similar kind of a problem. When you say we must open port 8887 you mention the port on the router or the port on the pc? Sorry if my question is stupid. Please I know that I was able to connect to its router using port 80. But if I send it a message it does not respond while for both the pc there is a program to attend the connection on port 80. Any help on this is highly appreciated. Thanks in advance.

  4. #4
    Join Date
    Nov 2009
    Posts
    359

    Re: Socket problem in java

    Hello,
    Must configure your friend's router to forward port 8887 on the computer running the server. Of course, it also requires the server is ready to receive a motion and must be launched and the firewall configured to accept incoming connections on that port. If you have any more queries regarding this topic then do post and we will help you solve your problem.

  5. #5
    Join Date
    Dec 2009
    Posts
    292

    Re: Socket problem in java

    Hello,
    One more question is not there a door provided for that referral directly on the local pc without me is whatever has to be set.
    What think you of this command in java (I can not make a walk):
    Code:
    msoc soc = new Socket (String host, int port, InetAdress adresseLocal, localPort int);
    If someone could give me more than it would permission. For I will absolutely do my program without configuring the router.

  6. #6
    Join Date
    Nov 2009
    Posts
    356

    Re: Socket problem in java

    Hello,
    this is not possible without touching the router's configuration, regardless of the program. The easiest way is to configure the router to return any default on the pc (DMZ). Nevertheless, we must configure the router and then offer it a usb modem. Hope you are understanding he problem and I would recommend you to read some basic of networking in java , then start the code part.

Similar Threads

  1. Replies: 6
    Last Post: 22-07-2011, 10:24 PM
  2. Problem communication SOCKET TCP / IP in Java
    By Fragant in forum Software Development
    Replies: 5
    Last Post: 14-09-2010, 07:03 PM
  3. What is socket and server socket in java?
    By Truster in forum Software Development
    Replies: 5
    Last Post: 01-02-2010, 02:08 PM
  4. Socket problem on Ubuntu
    By Sonic in forum Software Development
    Replies: 3
    Last Post: 11-04-2009, 06:24 PM
  5. MySQL: connection problem of socket
    By Bull50 in forum Software Development
    Replies: 4
    Last Post: 31-03-2009, 12:00 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,289,118.33592 seconds with 17 queries