title: How to run a live server win winsock?
body: <p>So I want to run a live server on my pc to connect and get info from someone else. I thought I can let the other person connect to my ip address on a port that is not used. So for example if my hypothetical ip address is 214.231.34.12 and port 50000 and I open te connection and give this information to someone, they can connect to it and send me information through TCP.</p>
  
  <p>I thought I could use this code:</p>
  
  <pre><code>// TCPClient.cpp : Defines the entry point for the console application.
  //
  #include "stdafx.h"
  #define _WINSOCK_DEPRECATED_NO_WARNINGS
  /*
  Live Server on port 50000
  */
  #include&lt;io.h&gt;
  #include&lt;stdio.h&gt;
  #include&lt;winsock2.h&gt;
  
  #pragma comment(lib,"ws2_32.lib") //Winsock Library
  
  int main(int argc, char *argv[])
  {
      WSADATA wsa;
      SOCKET s, new_socket;
      struct sockaddr_in server, client;
      int c;
      char *message;
  
      printf("\nInitialising Winsock...");
      if (WSAStartup(MAKEWORD(2, 2), &amp;wsa) != 0)
      {
          printf("Failed. Error Code : %d", WSAGetLastError());
          return 1;
      }
  
      printf("Initialised.\n");
  
      //Create a socket
      if ((s = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
      {
          printf("Could not create socket : %d", WSAGetLastError());
      }
  
      printf("Socket created.\n");
  
      //Prepare the sockaddr_in structure
      server.sin_addr.s_addr = inet_addr("214.231.34.12");
      server.sin_family = AF_INET;
      server.sin_port = htons(50000);
  
      //Bind
      if (bind(s, (struct sockaddr *)&amp;server, sizeof(server)) == SOCKET_ERROR)
      {
          printf("Bind failed with error code : %d", WSAGetLastError());
          exit(EXIT_FAILURE);
      }
  
      puts("Bind done");
  
      //Listen to incoming connections
      listen(s, 3);
  
      //Accept and incoming connection
      puts("Waiting for incoming connections...");
  
      c = sizeof(struct sockaddr_in);
  
      while ((new_socket = accept(s, (struct sockaddr *)&amp;client, &amp;c)) != INVALID_SOCKET)
      {
          puts("Connection accepted");
  
          //Reply to the client
          message = "Hello Client , I have received your connection. But I have to go now, bye\n";
          send(new_socket, message, strlen(message), 0);
      }
  
      if (new_socket == INVALID_SOCKET)
      {
          printf("accept failed with error code : %d", WSAGetLastError());
          return 1;
      }
  
      closesocket(s);
      WSACleanup();
  
      return 0;
  }
  </code></pre>
  
  <p>But it is failing at binding the connection. This whole TCP and winsocket stuff is totally new to me and I do not understand how I should approach this differently. I know this code is not receiving any information yet, it is just the connection that I try to get working at the moment. Is this not the right way to set this up?</p>
  
  <p>The bind() fails with windows socket error 10049</p>