Solved

UDP Instant Messaging Server

Posted on 2004-09-12
8
245 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
HashMap Vs TreeMap 12 55
JAVA part two 5 57
Requested array size exceeds VM limit 3 84
more than one jdk and one jre 1 32
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
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…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

910 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now