Solved

UDP Instant Messaging Server

Posted on 2004-09-12
8
260 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to get all the API from website? 11 106
check java version using powershell 13 181
eclipse buid path vs tomcat lib path 10 34
Java syntax, or is it Selenium 6 30
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
The viewer will learn how to implement Singleton Design Pattern in Java.

828 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