network-programming

Get index of network interface

假如想象 提交于 2019-12-23 16:26:35
问题 I'm writing simple sniffer for OS X on C So, I have a problem, I can't get index of network interface. I use this code: int sockfd=socket(PF_INET, SOCK_DGRAM, 0); if(sockfd<0) { printf("create socket"); fprintf(stderr, "%s\n",strerror(errno)); exit(EXIT_FAILURE); } sprintf( ifreq.ifr_name, "%s", "en0"); if(ioctl(sockfd, SIOCGIFINDEX, &ifreq)<0) { fprintf(stderr, "%s\n",strerror(errno)); exit(EXIT_FAILURE); } Problem that identifier 'SIOCGIFINDEX' is undeclared. Index of network interface need

what kind of fields in network packets should be converted to network byte order

北城以北 提交于 2019-12-23 14:20:07
问题 I know the endianess on hosts and network may be different but why the byte order is important? I think there are two reasons: 1 for the router to check the ip header(likeaddresses), the routers only recognize big-endian order(network byte order) 2 for the receiving host to recognize the byte order of the packets. Since the receiving host doesn't know the byte order of the sending host, if the byte order is not converted to network byte order, it doesn't know the packet byte order. am I right

Send a message back to a list of clients at any given time with async sockets in C#

守給你的承諾、 提交于 2019-12-23 13:15:13
问题 Ive got an async server set up, it works perfectly by connecting, receiving and sending back a message to the connecting client. The server itself is a Game-World-Server (mmorpg style). When a user sends its position to where its located, I need to push this out to all the clients with a PlayerPositionNotice. I know I'm missing some basic stuff here, but when i try to save the StateObject that was created in the accept method, and use that socket to send back information to the player at any

In Perl, how can I check for the existence of Socket options without generating warnings?

≡放荡痞女 提交于 2019-12-23 12:50:04
问题 I'm checking for the existence and default values of various socket options using Perl. #!/usr/bin/perl -w use strict; use Socket; if (defined(SO_BROADCAST)) { print("SO_BROADCAST defined\n"); } if (defined(SO_REUSEPORT)) { print("SO_REUSEPORT defined\n"); } When I run this it outputs: SO_BROADCAST defined Your vendor has not defined Socket macro SO_REUSEPORT, used at ./checkopts.pl line 9 Is there a way to do this without generating warnings in the output? 回答1: Ask whether the sub has been

Most efficient way to manipulate ISN numbers in TCP headers [closed]

女生的网名这么多〃 提交于 2019-12-23 12:26:28
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I am currently trying to write a program that will be able to create stable a TCP connection and have complete control over the ISN numbers. I've been writing in C and I am at a point where my very limited

how can i learn my client ip with .NET?

帅比萌擦擦* 提交于 2019-12-23 12:03:49
问题 i need my client ip from whatismyip.com. But Regex pattern is not correct i think? Can you help me this patttern? 回答1: This can be achieved way easier using the automation interface from www.whatismyip.com, so there's no need for any regex: static void Main(string[] args) { const string url = "http://www.whatismyip.com/automation/n09230945.asp"; var client = new WebClient(); try { var myIp = client.DownloadString(url); Console.WriteLine("Your IP: " + myIp); } catch (Exception ex) { Console

Is it possible to implement ping on windows phone 7?

元气小坏坏 提交于 2019-12-23 10:49:25
问题 To get the impression of networking capabilities in WP7 I was going to build a simple ping app that would display the result of ICMP ping request to a certain host. However, not only the System.Net.NetworkInformation.Ping class is missing, System.Net.Sockets namespace is missing as well. After a short research I found out that there are only two ways of communication in WP7: WebClient class that works with http(s) requests and WCF-client that works with SOA services. Does that mean that I can

How to quickly get the last line from a .csv file over a network drive?

旧街凉风 提交于 2019-12-23 10:24:11
问题 I store thousands of time series in .csv files on a network drive. Before I update the files, I first get the last line of the file to see the timestamp and then I update with data after that timestamp. How can I quickly get the last line of a .csv file over a network drive so that I don't have to load the entire huge .csv file only to use the last line? 回答1: There is a nifty reversed tool for this, assuming you are using the built-in csv module: how to read a csv file in reverse order in

What's the difference between “java.io.IOException: Connection timed out” and “SocketTimeoutException: Read timed out”

孤者浪人 提交于 2019-12-23 09:59:18
问题 If I set a socket SoTimeout, and read from it. when read time exceed the timeout limit, I'll get an "SocketTimeoutException: Read timed out". and here is the stack in my case: java.net.SocketTimeoutException: Read timed out at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.read(SocketInputStream.java:150) at java.net.SocketInputStream.read(SocketInputStream.java:121) at java.io.FilterInputStream.read(FilterInputStream.java:133) at org.apache.hadoop.ipc

Subnetting to split network into smaller networks [closed]

别说谁变了你拦得住时间么 提交于 2019-12-23 07:01:23
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I've been working on this problem but haven't made much progress. Could someone help me out? Your company is assigned the network address 214.56.78.0/24. The company has five work groups to support: Administration (11 hosts), Sales (32 hosts), Customer Support (41 hosts), Support servers (8 hosts), Web and