simple tcp socket programming
Roger Oberholtzer
roger
Mon May 17 11:59:43 PDT 2004
On Tue, 24 Feb 2004 23:39:45 +0800
"M.W. Chang" <mwchang at i-cable.com> wrote:
> > server.sin_port = htons((short) port);
> >
> > /* Set any socket/protocol options */
> > int on = 1;
> > setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *) &on,
> > sizeof(on));
> >> if (bind(sock, (struct sockaddr *)&server, sizeof server) < 0) {
>
> Thank you. Worked like a charm.
Great. BTW, the socket option for reusing the address may or may not be
needed. If the client and server will be on the same machine it will be
needed. So I usually just do it. However, if the two sides will always be on
a different machine, it may not be needed.
--
+????????????????????????????+???????????????????????????????+
? Roger Oberholtzer ? E-mail: roger at opq.se ?
? OPQ Systems AB ? WWW: http://www.opq.se/ ?
? Erik Dahlbergsgatan 41-43 ? Phone: Int + 46 8 314223 ?
? 115 34 Stockholm ? Mobile: Int + 46 733 621657 ?
? Sweden ? Fax: Int + 46 8 302602 ?
+????????????????????????????+???????????????????????????????+
More information about the Linux-users
mailing list