winapi - Can't bind to low port number (80) on XP sp3 -


I have received this code in my socket class:

  bool gscat :: listen ( Int port) {d- & gt; Socket = socket (AF_INET, SOCK_STREAM, 0); If (D-> Socket> = 0) {Soceder Eder; Sockaddr_in * a = (sockaddr_in *) and Ender; ZeroObj (W); A- & gt; Sin_family = AF_INET; A- & gt; Sin_port = htons (port); A-> Sin_addr.OsAddr = INADDR_ANY; If (dam (D-> socket, and ADR, sizf (ADR)) gt; = 0) {if (listen (D-> socket, somexone)! = SOCKET_ERROR) {true; } And {error (); }} And {error (); }} And {error (); }      return false; }  

The "error ()" method only calls WSAGetLastError and the error goes away and it describes the details of the app. Anyway it works fine on my machine (XP SP2), but my friends fails on the XP SP3 machine. Specifically the bind call fails and WSAGetLastError returns "2", which is also not a valid socket error code. Passed value of "port" is 80, I am running a simple HTTP server as a service UI. I'm not completely sure why I check> = 0, but it can be related to non-windows platforms. In any case, according to MSDN, there is a return code on the error for bind SOCKET_ERROR which is 1, so that the check should be fine.

Did I leave something simple?

Update: We just tried a separate port number '8888' and everything works according to the expectation, so it seems that the low port number is the issue. There is nothing to hear actively on the harbor before running my service, so I am thinking that there are some new permissions in SP3 which stops listening to ports; 1024 until they have some permissions, which are similar to Linux / Unix to work. However, I want to be able to sort it anyhow.

From the 0 to the port number 1023 and the operating system to bind them with administrative Privileges may be required. As a result, any application that attempts to use these ports should get privilege.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -