Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3852186
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:16:45+00:00 2026-05-19T17:16:45+00:00

I have a TCP Server/Client where the Server listens on port 5000 and the

  • 0

I have a TCP Server/Client where the Server listens on port 5000 and the Client outgoing port is 39000.

I have Stunnel set up on the Server:

[custom]
accept  = 6000
connect = 5000

… so it accepts connections on port 6000 and redirects it to 5000 (which my Server.c is listening on).

I tried to set up STunnel on the Client in the following way:

[custom_cl]
accept = 39000
connect = 192.168.1.3:6000

…so it accepts any data from port 39000 and sends it to the Server (let’s say it’s at 192.168.1.3) at port 6000.

My client has this code:

client_addr.sin_family = AF_INET;
client_addr.sin_port = htons(39000);
client_addr.sin_addr.s_addr = inet_addr("0.0.0.0");
bzero(&(client_addr.sin_zero),8);

if (bind(sock, (struct sockaddr *)&client_addr, sizeof(struct sockaddr))
                                                               == -1) {
     perror("Unable to bind");
     exit(1);
     }

…so that it will always send out on port 39000. My problem is that I receive an “Unable to bind: Address already in use” because (I’m guessing) STunnel is listening on port 39000. What should I be doing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T17:16:46+00:00Added an answer on May 19, 2026 at 5:16 pm

    You don’t need to bind a socket for outgoing connection (unless you know what you are doing and what for). You just need to create a socket and call connect(). You pass localhost (or 127.0.0.1) as destination address and 39000 as destination port.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small TCP server that listens on a port. While debugging it's
I have a server and a client app, my server listens on port 10015
I have written a C# server which listens for Tcp connections. A client can
I have a server-client application [TCP sockets, .NET 4.0].. the application about : do
I have a client/server program in TCP written in C, and I would like
I have a server application that receives some special TCP packet from a client
I have a java server which is using TCP and sockets to connect to
I have a service which listens for incoming connections on a TCP\IP port number
I have an java application using Socket TCP/IP and GUI. Server always listens connection
I have a java-based server that allows client applications to connect via other programming

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.