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

  • Home
  • SEARCH
  • 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 8716747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:09:35+00:00 2026-06-13T06:09:35+00:00

According to this article from msdn ( http://msdn.microsoft.com/en-us/library/windows/desktop/ms740496(v=vs.85).aspx ) the struct varies depending on

  • 0

According to this article from msdn (
http://msdn.microsoft.com/en-us/library/windows/desktop/ms740496(v=vs.85).aspx) the struct varies depending on which protocol is selected!

Now I want to use this code from http://www.intelliproject.net/articles/showArticle/index/check_tcp_udp_port to check if a port is open or not!

Now I have the struct sockaddr as follows:

struct sockaddr {
    ushort  sa_family;
    char    sa_data[14];
};

but need this strcuture:

struct sockaddr {
    short   sin_family;
    u_short sin_port;
    struct  in_addr sin_addr;
    char    sin_zero[8];
};

Which changes are necessary?

(Ws2_32.lib is linked and following includes

#define WIN32_LEAN_AND_MEAN

// sockets
#include "windows.h"
#include <winsock2.h>
#include <ws2tcpip.h>

Thx

  • 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-06-13T06:09:36+00:00Added an answer on June 13, 2026 at 6:09 am

    In sockets API the address structure to use depends on the protocol. If you are using IPv4, the structure you need is sockaddr_in.

    The sockets API appeared long ago when void * wasn’t in standard. Pointers to sockaddr are used all over the sockets functions in exactly the same way as we would use void * pointers. The functions expect you to pass the pointers to the structures related to protocols you use. The unpleasant thing is that you need a cast whenever you pass a pointer to your address structure, but there is nothing you can do about it.

    IPv4 example:

    struct sockaddr_in address;
    
    // ...
    
    memset( &address, 0, sizeof(address) );
    
    address.sin_family = AF_INET;
    address.sin_port = htons(1100);
    address.sin_addr.s_addr = INADDR_ANY;
    
    if ( bind( sock, (struct sockaddr *)&address, sizeof(address) ) < 0 )
    {
       //....
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a PHP-fpm setup on nginx setup according to this article: http://interfacelab.com/nginx-php-fpm-apc-awesome/ PHP
according to this article: http://net.tutsplus.com/tutorials/other/top-20-mysql-best-practices/ using ORDER BY RAND() is a bad idea because:
If I need to go from this service contract: [ServiceContract(Namespace=http://api.x.com/Svc1)] public interface IService1 {
According to this article , you can use the AbstractRoutingDataSource from Spring Framework to
According to this article from Herb Sutter, one should always pick Class Specializing over
According to this msdn article one of the sources for InitialDirectory property used in
These are taken from the tuts-premium Jquery vid tutorials. http://tutsplus.com/lesson/the-this-keyword/ Jeff explains what 'this'
According this article , generic JPA DAO(Data Access Object) is a pretty nice pattern.
According to this article , it says: Use a delegate in the following circumstances:
According to this article , it's possible to get multiline XML comments -- instead

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.