Solved

UDP Instant Messaging Server

Posted on 2004-09-12
8
235 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
Comment Utility
if the port is the nedxt token then:
String port = st.nextToken();

0
 

Author Comment

by:AnthonyCosenza
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 92

Assisted Solution

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

Author Comment

by:AnthonyCosenza
Comment Utility

how would this be done??
0
 
LVL 92

Assisted Solution

by:objects
objects earned 450 total points
Comment Utility
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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

762 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

10 Experts available now in Live!

Get 1:1 Help Now