Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

UDP Instant Messaging Server

Posted on 2004-09-12
8
Medium Priority
?
277 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 92

Accepted Solution

by:
objects earned 1350 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 1350 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 1350 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 1350 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 150 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

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…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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.
Suggested Courses

610 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