Article View: borland.public.jbuilder.java.api
Article #576Re: Sockets and Client/Server applications
From: Kevin Dean
Date: Fri, 13 Jun 2003 20:13
Date: Fri, 13 Jun 2003 20:13
56 lines
3888 bytes
3888 bytes
A server socket is one that listens on a specified port. When a client makes a connection on that port, it starts a unique conversation between it and the server. At that point, you can send whatever you like up and down the pipe as long as the client and the server agree on the data format. There will never be any conflict between one client and another. There is nothing preventing you from changing the data format to a byte stream for raw binary data and then switching it back again. The problem you will have in spawning a second server socket is this: suppose both client 1 and client 2 are instructed to make a connection on that socket. Client 1 is told first, 100ms before client 2. However, client 2 is faster and establishes the connection to the second server socket. Your server thinks it's talking to client 1 because that's the one that was told to initiate contact first. Your best bet is to use a single dedicated connection for your session. -- Check out our latest white papers at http://www.datadevelopment.com/papers/index.html BladeNET Scores With Borland Enterprise Tools Team Development with JBuilder and Borland Enterprise Server Dolphin Data Development Ltd. http://www.datadevelopment.com/ "Alan Shiers" <ashiers@hfx.eastlink.ca> wrote in message news:3EEA1B0B.F96AB3D@hfx.eastlink.ca... > > > What do you mean by "set to the same Port Number"? Are you talking > > about ServerSockets or client Sockets? Perhaps if you posted some > > code, it would be a little more clear what you are doing. > > Yes, I'm referring to ServerSockets. > Conceptually speaking this is all I'm trying to accomplish: > > I want one primary ServerSocket open with DataInputStream and > DataOutputStream classes connected to it, and remains listening to the > Port specified in the application, and for the duration that any Client > may be connected. Then, a separate secondary ServerSocket, which only > gets activated, on the fly, with BufferedInputStream and > BufferedOutputStream classes connected to it. > > The idea being that, the primary ServerSocket is used only to send > integer values (representing Constants defined in the application) back > and forth between the server app and the Client app. And the secondary > ServerSocket is used only to upload/download files at the byte level > only. > > So, the question remains, will there be a conflict of data transfer if > both ServerSockets are set to the same IP address and on the same Port > Number? Is it better to at least have each ServerSocket set to > different Port Numbers to prevent conflict of data transfer? > > Alan
Technical Details
Message-ID:
<3eea30b2$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-09!supernews.com!newsfeed.gamma.ru!Gamma.RU!newsfeed.media.kyoto-u.ac.jp!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailReferences:
<3EE34D95.E0767B34@hfx.eastlink.ca> <3ee4a9df$1@newsgroups.borland.com> <3EE4B19A.D1A9BF4@hfx.eastlink.ca> <3ee95418$1@newsgroups.borland.com> <3EEA1B0B.F96AB3D@hfx.eastlink.ca>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1089d0,21183e92a0cd9ddc X-Google-Attributes: gid1089d0,public X-Google-ArrivalTime: 2003-06-13 13:20:49 PST From: "Kevin Dean" <NkOdSePaAnM@datadevelopment.com> Newsgroups: borland.public.jbuilder.java.api References: <3EE34D95.E0767B34@hfx.eastlink.ca> <3ee4a9df$1@newsgroups.borland.com> <3EE4B19A.D1A9BF4@hfx.eastlink.ca> <3ee95418$1@newsgroups.borland.com> <3EEA1B0B.F96AB3D@hfx.eastlink.ca> Subject: Re: Sockets and Client/Server applications Date: Fri, 13 Jun 2003 16:13:32 -0400 Lines: 58 Organization: Dolphin Data Development Ltd. X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 24.57.150.243 Message-ID: <3eea30b2$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1055535282 24.57.150.243 (13 Jun 2003 13:14:42 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-09!supernews.com!newsfeed.gamma.ru!Gamma.RU!newsfeed.media.kyoto-u.ac.jp!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail