KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am following along with beej's guide to networking and it's been going REALLY good because I understand everything very well and he explains it great. however, when I want to test out some of the cool things he's showing me, it won't work!. :( I am not sure where exactly sockaddr_in is declared but maybe somebody here will so help me out! Here is what I have so far (testing out converting an ip in string form to an ip to a 4 byte integral and vice versa): #include <stdio.h> #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> int main(void) { sockaddr_in sin; inet_pton(AF_INET, "192.168.2.1", &sin.in_addr); char ip[INET_ADDRSTRLEN]; inet_ntop(AF_INET, &sin.in_addr, ip, INET_ADDRSTRLEN); printf("%s\n", ip); return 0; } Again I am completely clueless as to where everything is so if it's something really stupid on my part, sorry! Edit: I'm on a Linux Debian distro called Mint if that helps at all?
Tags (comma-separated)
Save Edits
Cancel