473,387 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

socket programming in C + multiple socket, same port num

15
Hi all,
I was trying to create 2 sockets to be able to establish 2 connections to a client. The first socket supposedly to facilitate the DH algo which I wanted to implement and the second socket to only accept byte streams as input. I always get "unable to bind" even though I've used the close() and shutdown() function to close the first socket. Can anyone help show me the way here?
Apr 17 '09 #1
6 4715
gpraghuram
1,275 Expert 1GB
Ususally shutdown shuld be called from server side and close from client side.
As u cal shutdown you shuld be able to use the same port.

Raghu
Apr 20 '09 #2
boddah
15
@gpraghuram
Yes Raghul, I'm aware of that. But still I'm unable to bind the socket to the port.
Apr 20 '09 #3
gpraghuram
1,275 Expert 1GB
After calling shutdown tru to run netstat and see whether the port is released or some other process is using that port.

Raghu
Apr 21 '09 #4
boddah
15
After creating the 1st socket, a client successfully connects to it and closed its connection. When the server tries to bind for the second socket, it fails and the app exits. Hence, the 2nd client unable to connect. Any way i can solve this?
Apr 21 '09 #5
gpraghuram
1,275 Expert 1GB
Hi,
i am getting ur question.
Usually after shutdown this behaviour dosent happen.
So to understand whats happenening after running the first application run netstat and see whats happening to the port or somebody is using it.

Then run the second program if the port is not used by any body.

Raghu
Apr 23 '09 #6
I'm quite new to the use of sockets but I think this might have to do with the "TIME-WAIT" state (which often takes up to 4 minutes, and is there to deal with wandering packages etc.)
Oct 21 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Jason | last post by:
After a server accepts a client connection on a certain port, a new socket is created on the server on a system managed dynamic port to handle the connection. Please confirm this. If so, how...
2
by: priya | last post by:
Hi All, Currently I am working in Socket Progrm written in C. Here i pasted Both Server and client code.. Server.c code
1
by: Rolln_Thndr | last post by:
I'm vey new to network programing and have a few rather fundemental questions. I'm creating a very basic UDP proxy server and having a few issues regarding the sockets. Is it possible to change...
5
by: John Sheppard | last post by:
Hi all, I am not sure that I am posting this in the right group but here it goes anyway. I am new to socket programming and I have been searching on the internet to the questions I am about to pose...
13
by: coloradowebdev | last post by:
i am working on basically a proxy server that handles requests via remoting from clients and executes transactions against a third-party server via TCP. the remoting site works like a champ. my...
10
by: Uma - Chellasoft | last post by:
Hai, I am new to VB.Net programming, directly doing socket programming. In C, I will be able to map the message arrived in a socket directly to a structure. Is this possible in VB.Net. Can...
1
by: mirandacascade | last post by:
I noticed the following lines from the connect() method of the HTTPConnection class within httplib: for res in socket.getaddrinfo(self.host, self.port, 0, socket.SOCK_STREAM): af, socktype,...
6
Sagittarius
by: Sagittarius | last post by:
I will first try to describe my problem in words. I have a simple program, written in C++, that needs to send a single bytearray via a UDP socket to a microprocessor, which returns an answer, also...
0
by: kaps | last post by:
Hi all, After reading for a while I have successfully prepared a server side listening and accepting multiple connections, and a client connecting to server. I need help on loop of send/receive...
4
by: O.B. | last post by:
I have a socket configured as TCP and running as a listener. When I close socket, it doesn't always free up the port immediately. Even when no connections have been made to it. So when I open...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.