Results 1 to 2 of 2
  1. #1
    omsh12 is offline Member
    Join Date
    Jun 2012
    Posts
    6
    Rep Power
    0

    Default Connecting server and client

    I have a problem that when i use ServerSocket.accept() the program stops working until it recives a connection request from the client, my question is , Is there a way that while the ServerSocket is waiting for a client my program will continue working and when a client requests to connect the program will treat it like an event listener and activate a certain function

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Connecting server and client

    Quote Originally Posted by omsh12 View Post
    I have a problem that when i use ServerSocket.accept() the program stops working until it recives a connection request from the client, my question is , Is there a way that while the ServerSocket is waiting for a client my program will continue working and when a client requests to connect the program will treat it like an event listener and activate a certain function
    Yes, do your accept in a background thread. For more on Java threading, please check out the Concurrency Tutorial.
    Last edited by Fubarable; 06-30-2012 at 01:24 PM.

Similar Threads

  1. Replies: 3
    Last Post: 06-03-2012, 09:48 AM
  2. Replies: 1
    Last Post: 06-03-2012, 03:07 AM
  3. Replies: 9
    Last Post: 05-28-2011, 09:13 PM
  4. Replies: 2
    Last Post: 09-24-2010, 11:31 AM
  5. Identify Client in Socket Client Server Application
    By masadjie in forum Networking
    Replies: 1
    Last Post: 12-20-2007, 09:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •