Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > serversocket

Reply
Thread Tools

serversocket

 
 
Lucyann Lenon Emerick De Assis
Guest
Posts: n/a
 
      07-16-2012
Em segunda-feira, 16 de julho de 2012 08h49min06s UTC-3, Lucyann Lenon Emerick De Assis escreveu:
> Well, first I thank you for the answer, and guidelines apply to my learning!
> the customer is a good model tk 102 gps, if not I engando communicates via tcp.
> What struck me is that the same code works on a smartphone, I used the tracker to emulate mylive sending data tk 102
> Em sábado, 14 de julho de 2012 18h12min22s UTC-3, Lew escreveu:
> > Lew wrote:
> > ... [snip] ...
> > > /* Track
> > > * $RCSfile$
> > > */
> > > package eegee;
> >
> > ...
> >
> > > public class Track
> > > {
> >
> > ...
> >
> > > private static void serveConnections(ServerSocket serverSocket)
> > > {
> > > while (true)
> > > {
> > > final Socket connectionSocket;
> > > try
> > > {
> > > connectionSocket = serverSocket.accept();
> > > }
> > > catch (IOException exc)
> > > {
> > > logger.error(BAD_CONNECT, exc);
> > > return;
> > > }
> > > assert connectionSocket != null;
> > >
> > > try
> > > {
> > > handleClient(connectionSocket);
> > > }
> > > finally
> > > {
> > > close(connectionSocket);
> > > }
> > > }
> > > }
> > ...
> >
> > I made a mistake in the 'serveConnections()' method,arguably. Or maybe it
> > isn't a mistake.
> >
> > What do you think; is it a mistake or not?
> >
> > --
> > Lew
> > Honi soit qui mal y pense.
> > http://upload.wikimedia.org/wikipedi.../c/cf/Friz.jpg

you're telling me I have to create a client and not a server socket?, and as I receive data connection?
 
Reply With Quote
 
 
 
 
Lew
Guest
Posts: n/a
 
      07-16-2012
Lucyann Lenon Emerick De Assis wrote:
> Lew escreveu:
>> Lew wrote:
>> ... [snip] ...


> you're telling me I have to create a client and not a server socket?, and as I receive data connection?


No.

I am showing you how to do exactly what you did with your original
code sample, to wit, set up a socket server, with less risk of bugs
than in your original code.

I have no idea if what you showed will do what you want. You haven't
provided enough data that I can use to answer that.

Others have asked the relevant questions.

Namely, if the device connects to your server as a client, then you
write the server code something along the lines shown above.

Is that how the device works?

--
Lew
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to kill thread which is blocked by Serversocket.accept()? Jan Liße Java 15 02-19-2004 10:11 PM
Unusual ServerSocket Behaviour Thomas Hawkins Java 3 01-30-2004 08:44 PM
ServerSocket and ClientSocket - bi-directional Abraham Khalil Java 1 01-26-2004 06:03 AM
Socket / ServerSocket & Remote Disconnection Detecting Jason Teagle Java 12 10-05-2003 10:23 AM
Restrict ports of ServerSocket.accept() sockets Thomas Kuhn Java 4 07-07-2003 08:49 AM



Advertisments