#23 winsock1/winsock2 differences

WSL
closed
None
fixed
Known_bugs
2013-02-04
2001-02-08
Danny Smith
No

This bug was reported in Nov 2000 to mingw-usr
Yes it is a bug
I have fix, but await commit of my patch to winsock.h

--- Dmitriy Skorodumov <dskorodumov@warpsolutions.com> wrote: > From: "Dmitriy Skorodumov" <dskorodumov@warpsolutions.com>
> To: <mingw-users@lists.sourceforge.net>
> Date: Tue, 14 Nov 2000 00:13:02 +0300
> Subject: [Mingw-users] libws2_32.a bug
>
> Attached program work well, while compiled using MSVC:
> cl test.cpp ws2_32.lib
>
> It also work well while compiling with mingw-msvcrt 2.95.2-1 using
> command-line
> g++ test.cpp -lwsock32
>
> but with command line
> g++ test.cpp -lws2_32
>
> it is failed with WSAError "Protocol not supported"..
>

> ATTACHMENT part 2 application/octet-stream name=test.cpp
#include <winsock2.h>
#ifndef __GNUC__
#include <ws2tcpip.h>
#endif
#include <iostream.h>

SOCKET _sock;

bool addMulti(struct in_addr ip,struct in_addr iface)
{
struct ip_mreq mc;
memset(&mc,0,sizeof(mc));
mc.imr_multiaddr=ip;
mc.imr_interface=iface;

if (setsockopt(_sock,IPPROTO_IP,IP_ADD_MEMBERSHIP,(char *)&mc,sizeof(mc))<0) {
return false;
}
return true;
}

int main()
{
WSADATA wsaData;
WSAStartup(MAKEWORD(2,2), &wsaData);
_sock = socket(PF_INET, SOCK_DGRAM, 0);
int opt;
opt=1; setsockopt(_sock,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(opt));
opt=1; setsockopt(_sock,SOL_SOCKET,SO_BROADCAST,(char *)&opt,sizeof(opt));

struct sockaddr_in sin;
memset(&sin,0,sizeof(sin));
sin.sin_family=AF_INET;
sin.sin_port=htons(46374);
if (bind(_sock,(struct sockaddr *)&sin,sizeof(sin))<0) {
cout<<"Error binding!\n";
return -1;
}
struct in_addr multi;
multi.s_addr=inet_addr("224.5.6.7");

struct in_addr null;
memset(&null,0,sizeof(null));

if( !addMulti(multi,null) )
{
cout << "Failed to join to mcast group" << endl;
return -1;
}
cout<<"Ok\n";

return 0;
}

Discussion

  • Danny Smith

    Danny Smith - 2001-02-08
    • assigned_to: nobody --> dannysmith
     
  • Danny Smith

    Danny Smith - 2001-02-21
    • status: open --> closed-fixed
     
  • Danny Smith

    Danny Smith - 2001-02-21

    Updated winsock headers (22 Feb 2001 NZDT) fix.

     
  • Earnie Boyd

    Earnie Boyd - 2013-02-04
    • labels: w32api (deprecated use WSL) -->
    • status: closed-fixed --> closed
    • resolution: --> fixed
    • category: --> Known_bugs
    • milestone: Known_bugs --> WSL
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks