Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-07-2007, 02:33 PM
Member
 
Join Date: Nov 2007
Posts: 3
bluebarca is on a distinguished road
Multithreading + Networking (desperate)
i'm trying to implement a simple p2p server.
the server should listen on a port for incoming connection and when there is it launches a new thread which will accept the connection and open a TCP port with this client.

before anything the client should send his username and version of prog he is using.

1- how can i implement threading that will allow to many users to connect to this server at the same time. (how will i differentiate between them if they use the same socket).

2- if the user send his username ... i store this in a string on the server and check for it, then he sends his password how will i check, will i override the prev string ( how will i know that the name ended and the password started)

Please helppp !!!!!!
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-07-2007, 03:14 PM
JavaBean's Avatar
Moderator
 
Join Date: May 2007
Posts: 1,272
JavaBean is on a distinguished road
Check this tutorial:

Writing the Server Side of a Socket (The Java™ Tutorials > Custom Networking > All About Sockets)

All you want is described in this tutorial in a step by step manner.

1. For handling multiple clients, check "Supporting Multiple Clients" section.

2. For username/passowrd, you will need t oimplement your own protocol just like they implemented The Knock Knock Protocol. In the first stage, you should accept the username. For example, you can have a predefined string for each command (e.g. PASS for password and USER for username) and your client can send that that string before user/pass. But note that all depend on your decisions: If you define to send password first before the username, that is a solution too!
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java networking. tim New To Java 6 01-05-2008 07:31 PM
Java networking programming (II) Java Tutorial Java Tutorials 0 12-27-2007 07:19 PM
Java networking programming (I) Java Tutorial Java Tutorials 0 12-24-2007 08:21 PM
Why use multithreading? JavaForums Java Blogs 0 12-17-2007 01:21 PM
Multithreading (basics) JavaForums Java Blogs 0 12-17-2007 01:21 PM


All times are GMT +3. The time now is 03:48 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org