Results 1 to 13 of 13
  1. #1
    KaustubhB is offline Member
    Join Date
    Apr 2012
    Posts
    7
    Rep Power
    0

    Default Regarding server sockets

    I am creating a chat application in which server can provide Relay Chat as well as instant messaging. i have finished the relay chat part. My application can also generate list of users that are logged in on server side. I am using objectoutputstream to send that list but my server is getting disconnected. i am sending on same socket which serversocket.accept() method spawns which sends my messages too..
    my question is can a two server sockets can be opened at the same time on a single ip but different ports... coz i tried doing tht and still connection is getting reset i am doing this on localhost...

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default Re: Regarding server sockets

    Have you tried it? You should be able to use ServerSockets with different ports with no problems.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    KaustubhB is offline Member
    Join Date
    Apr 2012
    Posts
    7
    Rep Power
    0

    Default Re: Regarding server sockets

    Thanks dude
    i was doing a very silly mistake while serializing objects
    and your answer is correct.
    i just wrote a statement that prints all the connections serversocket accepts
    finally the list of users is getting transported
    THANK YOU SO MUCH....

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default Re: Regarding server sockets

    Often just trying it will give you the answer saving a post.
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    KaustubhB is offline Member
    Join Date
    Apr 2012
    Posts
    7
    Rep Power
    0

    Default Re: Regarding server sockets

    Ok i got one more glitch. see there is a list of clients which is getting populated once a client is connecting or disconnecting to the server this list is stored in a string array which is then sent to other users by means of object serialization and objectoutput stream. the thing is i m not closing the this stream and object is sent only once that is the list is sent only once .
    my question is do u have to close the objectoutput stream every time ?? how to read the list if we r not closin the output stream ?? and i dont know whether object is being recieved multiple times.....
    plz help

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default Re: Regarding server sockets

    You would close the stream when you are done with it. If you want to continue using it, try calling flush().
    i dont know whether object is being recieved multiple times.....
    If you send it once, you should receive it once. Why do you think it might be receiving it multiple times?
    If you don't understand my response, don't ignore it, ask a question.

  7. #7
    KaustubhB is offline Member
    Join Date
    Apr 2012
    Posts
    7
    Rep Power
    0

    Default Re: Regarding server sockets

    The list is getting updated every time and is getting stored in the string array then serialized array is sent many times over the socket i m using flush() after sending the array its the receiving i m having problem with ....
    the array is sent properly for the first time but when another client connects to the server the list gets updated and is sent again i don't know whether the array is sent again or whether m having problem in the receiving end.
    so again ma question is can one use the stream more than once for sending the serialized object..
    sorry for asking u silly questions but i m not getting this for a while and its one module of ma engineering project and i m about to get ma final degree and super tensed ...

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default Re: Regarding server sockets

    can one use the stream more than once for sending the serialized object..
    There shouldn't be any restrictions on what is sent or how often it is sent over a stream.

    i don't know whether the array is sent again or whether m having problem in the receiving end.
    Do some debugging. Print out what is sent and what is received.
    If you don't understand my response, don't ignore it, ask a question.

  9. #9
    KaustubhB is offline Member
    Join Date
    Apr 2012
    Posts
    7
    Rep Power
    0

    Default Re: Regarding server sockets

    I completed the chat client i was doing a mistake while reading later i had to use oos.reset() now i m facing a problem regarding swings
    norm dude u rock
    can u plz help me in this i m kinda in a very bad position
    i was integrating all the modules for UI
    now i m facing a problem where i spawn a main window and text area is updated from other class problem is am the output stream of the client side is getting closed after first instance
    n i ll mail u da code of ma project if u ll plz help me i m having a deadline to dayafter tommorow....

  10. #10
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default Re: Regarding server sockets

    Please use normal English in your posts.
    Waiting for a properly spelled post.
    If you don't understand my response, don't ignore it, ask a question.

  11. #11
    KaustubhB is offline Member
    Join Date
    Apr 2012
    Posts
    7
    Rep Power
    0

    Default Re: Regarding server sockets

    Ok.
    Sorry i am kinda weak at phrasing sentences in english
    see i have 4 modules of my project
    one of them is chat which deals with relaychat as well as private messaging
    I have completed this module and gave it a temporary GUI using swings
    Now when i am integrating it with the applications UI i am facing a problem
    can i mail u the code so u can look into it ll be better to explain what problem i am facing .. and we can chat via gtalk or something...

  12. #12
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default Re: Regarding server sockets

    Sorry, no private work. Post what you want to discuss here. Make a small, simple program that compiles, executes and shows the problem.
    If you don't understand my response, don't ignore it, ask a question.

  13. #13
    KaustubhB is offline Member
    Join Date
    Apr 2012
    Posts
    7
    Rep Power
    0

    Default Re: Regarding server sockets

    I have to meet a deadline and i m going to do it anyway so thanks for helping ...
    U can close this thread
    i ll go back to books ...

Similar Threads

  1. Server Sockets sending images from URL
    By devett in forum Networking
    Replies: 1
    Last Post: 06-07-2011, 07:25 AM
  2. Client and Server sockets on same machine
    By Yogesh_P in forum Networking
    Replies: 3
    Last Post: 03-28-2011, 04:10 PM
  3. Java Server & C# client communicating through sockets
    By yukijocelyn in forum Networking
    Replies: 0
    Last Post: 09-05-2008, 10:05 PM
  4. An echo server using UDP sockets
    By Java Tip in forum java.net
    Replies: 0
    Last Post: 04-07-2008, 08:09 PM

Posting Permissions

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