Re: [Dev-C++] Know any docs on <wininet.h> ?
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Reid T. <rei...@at...> - 2004-01-18 18:04:12
|
is this the example you speak of? If so, cygwin works fine with it.
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <netinet/in.h>
int
make_socket (uint16_t port)
{
int sock;
struct sockaddr_in name;
/* Create the socket. */
sock = socket (PF_INET, SOCK_STREAM, 0);
if (sock < 0)
{
perror ("socket");
exit (EXIT_FAILURE);
}
/* Give the socket a name. */
name.sin_family = AF_INET;
name.sin_port = htons (port);
name.sin_addr.s_addr = htonl (INADDR_ANY);
if (bind (sock, (struct sockaddr *) &name, sizeof (name)) < 0)
{
perror ("bind");
exit (EXIT_FAILURE);
}
return sock;
}
----------------------------
Compile and run this. You then have 20 seconds ( sleep(20)) when you
can run 'netstat -an | grep 54000' which should show the socket
listening on 54000.
TCP 0.0.0.0:54000 0.0.0.0:0 LISTENING
------
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <netinet/in.h>
int make_socket(uint16_t port);
int main(void)
{
int socka = 0;
int mysock = 0;
mysock = make_socket(54000);
printf("mysock[%d]\n", mysock);
return(0);
}
int make_socket(uint16_t port)
{
int sock;
struct sockaddr_in name; /* Create the socket. */
sock = socket(PF_INET, SOCK_STREAM, 0);
if (sock < 0)
{
perror("socket");
exit(EXIT_FAILURE);
} /* Give the socket a name. */
name.sin_family = AF_INET;
name.sin_port = htons(port);
name.sin_addr.s_addr = htonl(INADDR_ANY);
if (bind(sock, (struct sockaddr *) &name, sizeof(name)) < 0)
{
perror("bind");
exit(EXIT_FAILURE);
}
sleep(20);
return sock;
}
* William wrote:
> Thanks to Reid.
>
> Now I have a real 'question' ... or can it be a challenge to implementors.
>
> The most recent Dev CPP help for C (which appears to be GNU GCC
> documentaion) shows good examples for inet.
>
> Cygwin and mingw don't appear to implement this functionality (so far...
> still looking).
>
> The 'challenge' is to inentify the library (.a file) that each header (.h
> file) belongs too and what is and not-quite implemented.
>
> Example; SIGKILL isn't implemented in mingw. No big deal, use SIGTERM (may
> be) ... consistiently there is bulk documetation on either std *NIX and GNU
> stuff. the Most important thing is (to me) the differences and
> alternatives.
>
> My progress so far is that mingw and cygwin don't appear to have "inet"
> functionality except for the mingw winiwn.h interface. Still investigating.
>
> As my target it Windows, I think a networking module might correctly be
> platform dependant and would like to find the documents for the "wininet.h"
> interface.
>
>
> On a minor point -- is the dev Pascal project still running ... ?
>
> Thanks for the time.
>
> Aloha,
> w
>
>
>
> ----- Original Message -----
> r> From: Reid Thompson
> r> Sent: Sunday, January 18, 2004 8:26 AM
> r>
> r> look at/download cygwin www.cygwin.com
> r>
> r> * William wrote:
>
>>I want the 'equivalent' or either
>>
>> <netinet/in.h> ... or ...
>> <in.h>
>>
>>I have found <wininet.h> in the folder. Can someone point me to
>>documentation on this file please ? (Oh yes the context is from a gawk
>>project. )
>
>
>
>
> -------------------------------------------------------
> The SF.Net email is sponsored by EclipseCon 2004
> Premiere Conference on Open Tools Development and Integration
> See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
> http://www.eclipsecon.org/osdn
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|