cygwin

I am beginning network progaming in windows i instaled Cygwin but i don't no how to use it.
Last edited on
Interesting.
I am waiting
anybody
closed account (z05DSL3A)
Why don't you start by reading the documentation!
http://www.cygwin.com/

... but my real advice to you is, if you want to learn network programming on the Windows platform, learn how to do it on the Windows platform, don't piss around with some notion that trying to learn how to do it in a cross platform manner is somehow going to be easier than just learning the one API.


... and read http://www.cplusplus.com/forum/beginner/1/ , asking a better question will get you a better response.
I like to do on windows platform but ever i search for ebooks i find them for linux and i can't find for windows maybe i should instal linux but i never used it do you suggest me using linux or no
closed account (z05DSL3A)
maybe i should instal linux but i never used it do you suggest me using linux or no

No, I would not recommend installing Linux (because I know nothing about your abilities, not because I think it is bad).

How about ebooks for windows network progamming does any one know a good one..
do you use linux
closed account (z05DSL3A)
You could look for a copy of "Network Programming for Windows", there are loads of tutorials on winsock on the net, or just start with MSDN: http://msdn.microsoft.com/en-us/library/ms740673(VS.85).aspx

I have Linux installed on one of my machines. It runs as a server so I don't use it as a desktop system.
I use linux as a desktop system, If you want to dual boot go for it but I would also suggest you think carefully and perhaps install linux on a spare machine first to just have a bit of a play around with rather then jumping straight in.

I would recomend you read beej's network programing guide first so you have an idea about socket programing: (do note this is for unix however the winsock functions are basically the same, if you know the unix stuff the winsock will be a piece of cake)

http://beej.us/guide/bgnet

other then that, have a look at the MSDN as grey wolf said. Come back with questions!
Are struggling with just Network Programming or Programming in general? It's not clear.
just network programming
So what environment did you use before? Surely you can do network programming there too, right?
I am using visual C++ 2008 and windows vista i program in win32 and console
Last edited on
closed account (z05DSL3A)
@kbw,

this is what has already been covered:
http://www.cplusplus.com/forum/general/14475/
Thanks Grey Wolk. Wow, all this started by a throw away comment.

See:
http://www.cplusplus.com/forum/windows/14392/

Here's your code, I've used the Windows headers. You'll need to add the WSAStartup/WSACleanup stuff to run it.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <stdio.h>
#include <string.h>
#include <sys/types.h>

#ifdef _WIN32
	#include <winsock2.h>
	#include <ws2tcpip.h>
#else
	#include <sys/socket.h>
	#include <netdb.h>
	#include <arpa/inet.h>
#endif

int main(int argc, char *argv[])
{
	struct addrinfo hints, *res, *p;
	int status;
	char ipstr[INET6_ADDRSTRLEN];

	if (argc != 2)
	{
		fprintf(stderr,"usage: showip hostname\n");
		return 1;
	}

	memset(&hints, 0, sizeof hints);
	hints.ai_family = AF_UNSPEC; // AF_INET or AF_INET6 to force version
	hints.ai_socktype = SOCK_STREAM;

	if ((status = getaddrinfo(argv[1], NULL, &hints, &res)) != 0)
	{
		fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(status));
		return 2;
	}
	printf("IP addresses for %s:\n\n", argv[1]);
	for (p = res;p != NULL; p = p->ai_next)
	{
		void *addr;
		char *ipver;

		// get the pointer to the address itself,
		// different fields in IPv4 and IPv6:
		if (p->ai_family == AF_INET)
		{ // IPv4
			struct sockaddr_in *ipv4 = (struct sockaddr_in *)p->ai_addr;
			addr = &(ipv4->sin_addr);
			ipver = "IPv4";
		}
		else
		{ // IPv6
			struct sockaddr_in6 *ipv6 = (struct sockaddr_in6 *)p->ai_addr;
			addr = &(ipv6->sin6_addr);
			ipver = "IPv6";
		}

		// convert the IP to a string and print it:
		inet_ntop(p->ai_family, addr, ipstr, sizeof ipstr);
		printf(" %s: %s\n", ipver, ipstr);
	}
	freeaddrinfo(res); // free the linked list
	return 0;
}
Last edited on
Topic archived. No new replies allowed.