• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Question about "socket"

Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wanna create a client-server application and need to transfer various kinds of information between C-S, these information includes identity validation , talking and some others : And my question is : Can i declare numbers of input streams and output streams in a single socket connection just like "new data input stream(socket.getinput stream() )"? If yes , How can i do that ?If no, Does that mean i should creat numbers of input(output)streams for each kinds of information using numbers of socket connection ? I am looking forward to receiving your earliest reply . Thanks !
Author & Gold Digger
Posts: 7617
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please do not crosspost the same topic in multiple forums.
I'm moving this thread to the Sockets and Internet Protocols forum. Please continue this discussion there.
This topic is now closed. Thank you
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the answer is no.
Besides, why would you want to have differnt streams for different information.
Just send it all down the same socket, and label the message so that the server can find out the type of message sent.
for example:
CLIENT sends the following message to server requesting to logon:
/logon: <username> <password>


msgType = inMsg.substring(0,<index of :> ;
// store IP, check username and pw against a db.
else if(msgType.equals(Messages.LOGOFF))
// log the user off, i.e. remove there IP address from some static list

Hope this helps.
author and iconoclast
Posts: 24203
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James' reply suggests that, with a bit of work, you could have multiple input and output streams working through a single socket -- but you'd have to write a multiplexer and demultiplexer yourself, as well as the custom stream types. Basically you'd do what James describes, but implement the InputStream and OutputStream protocols in doing so. Not for the faint of heart!
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic