Solved

UDP Instant Messaging Server

Posted on 2004-09-12
8
252 Views
Last Modified: 2010-03-31
As part of the server i need a statement that will return the host name that is given by the client as well as the port of the client the other client asks for.

Here is the snipit of wat i hav so far..

            // Part of if statement to handle "where" command
            } else if (received.startsWith("where")) {
                String host = st.nextToken();
               

                retMes = "@"+host+":"+userport;

wat needs to go in the middle??
0
Comment
Question by:AnthonyCosenza
  • 4
  • 3
8 Comments
 
LVL 92

Accepted Solution

by:
objects earned 450 total points
ID: 12040848
if the port is the nedxt token then:
String port = st.nextToken();

0
 

Author Comment

by:AnthonyCosenza
ID: 12040870
the thing is the port isnt a token

there is no next token....

all i hav is the client name to get the port number of that client with
0
 
LVL 92

Assisted Solution

by:objects
objects earned 450 total points
ID: 12040878
then get the port number from thr DatagramSocket.
Why do you need to pass that back to the client anyway? Can't it get it from the socket.

0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

Author Comment

by:AnthonyCosenza
ID: 12040915
the way this part works:

1. a client sends a who <username> to server (username bein another client)
2. server looks through to get the host name
3. returns @host:port back to the first client (where host and port are details of the second client)

hope that clears it up
0
 
LVL 92

Assisted Solution

by:objects
objects earned 450 total points
ID: 12040930
I see, then you need to lookup the socket for the other client and get the port number.
0
 

Author Comment

by:AnthonyCosenza
ID: 12040955

how would this be done??
0
 
LVL 92

Assisted Solution

by:objects
objects earned 450 total points
ID: 12040973
your server would need to keep a mapping for the socket used by each client, allowing the server to look up the socket used by a particular username.
0
 
LVL 2

Assisted Solution

by:gen718
gen718 earned 50 total points
ID: 12041253
Do you want each client to connect with each other independent of the server once the server responds with the "who" response? Or will all packets go thru the server?

Also, embedding host info in the packets can be a concern. This usually leads to problems when running behind a firewall. Also, are all domain/host names reachable? GetByName might not resolve for private host names.

Just some thoughts. What you think objects?

0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Basic Java Case or If-Else statement... 3 51
reverse digits of a number using for loop 5 42
spring jars download 1 27
Java Restore security prompts not working 10 13
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question