network-programming

How to determine the subnet mask and network interface card from remote SSH login?

扶醉桌前 提交于 2020-01-17 02:53:05
问题 In a separate question (link below), it was suggested that I obtain the network interface card number and subnet mask from a remote SSH login, rather than prompting the user for it. All I have is the IP address of my remote host. I need to obtain the subnet mask to determine if the remote and local host are on the same subnet, and the interface card number to set up and configure a virtual IP for aliasing purposes. Could someone suggest how I might be able to parse out the necessary

recv with flags MSG_DONTWAIT | MSG_PEEK on TCP socket

天大地大妈咪最大 提交于 2020-01-16 18:13:44
问题 I have a TCP stream connection used to exchange messages. This is inside Linux kernel. The consumer thread keeps processing incoming messages. After consuming one message, I want to check if there are more pending messages; in which case I would process them too. My code to achieve this looks like below. krecv is wrapper for sock_recvmsg(), passing value of flags without modification (krecv from ksocket kernel module) With MSG_DONTWAIT, I am expecting it should not block, but apparently it

Why does my client Socket not connect to my ServerSocket?

别来无恙 提交于 2020-01-16 04:34:07
问题 In this extremely basic client/server socket program, why does my client socket never connect and throw java.net.ConnectException ? I am running the MessageServer program on one computer, and the ClientServer program on another laptop on the same network. I have verified that the local-ip of the computer which is running the server program is 10.0.0.1 using the ipconfig command in the windows cmd on that computer. Server: package server; import java.net.*; import java.io.*; public class

Windows 7 vs. XP GetIsNetworkAvailable() difference?

喜夏-厌秋 提交于 2020-01-15 20:19:51
问题 I wrote code to populate a menu with the available IPv4 NICards on a machine. It has been tested on an XP machine and it seems all fine and well (it was also built on XP). I had it tested on Windows 7 and it always populated 2 IP address even if one was disconnected. Here are the results for the Win7 machine: WLAN Connected LAN Disconnected Observed: Correct WLAN address shows, Incorrect LAN address shows (it is even a different network number where it's connected to 192.168 however the LAN

Can't read in HTML content from valid URL

馋奶兔 提交于 2020-01-15 09:39:07
问题 I am trying out a simple program for reading the HTML content from a given URL. The URL I am trying in this case doesn't require any cookie/username/password, but still I am getting a io.IOException: Server returned HTTP response code: 403 error. Can anyone tell me what am I doing wrong here? (I know there are similar question in SO, but they didn't help): import java.net.*; import java.io.*; import java.net.MalformedURLException; import java.io.IOException; public class urlcont { public

Fill data into the recv-Buffer locally

有些话、适合烂在心里 提交于 2020-01-14 10:42:36
问题 I hook into the send and recv functions in Windows. In some situations I modify the data that's going to be sent and read. In the send function, this is easy. I hook into the function, modify the source buffer and then pass it to the original function. But for the recv function, this is more complicated. When I've called the original recv function and I'm going to decide to add more data, I need to push data into the local queue so that the next call of recv would return those bytes. Any

C#: get information about computer in domain

谁说胖子不能爱 提交于 2020-01-14 08:06:46
问题 What classes should I use in C# in order to get information about a certain computer in my network? (Like who is logged on that computer, what Operating System is running on that computer, what ports are opened etc) 回答1: WMI Library and here is a VB.net example. It shouldn't be difficult to convert it to C# 回答2: Checkout System.Management and System.Management.ManagementClass. Both are used for accessing WMI, which is how to get the information in question. Edit: Updated with sample to access

C#: get information about computer in domain

回眸只為那壹抹淺笑 提交于 2020-01-14 08:06:30
问题 What classes should I use in C# in order to get information about a certain computer in my network? (Like who is logged on that computer, what Operating System is running on that computer, what ports are opened etc) 回答1: WMI Library and here is a VB.net example. It shouldn't be difficult to convert it to C# 回答2: Checkout System.Management and System.Management.ManagementClass. Both are used for accessing WMI, which is how to get the information in question. Edit: Updated with sample to access

Generics and ReadObject

前提是你 提交于 2020-01-14 01:36:15
问题 I have a simple server that uses generics and object serialization. (T is the input format, U is the output format). A simplified version that only deals with input is shown below: public class Server <T, U> implements Runnable { @override public void run () { try (ObjectInputStream inReader = new ObjectInputStream (this.connection.getInputStream ())) { T lastObj; while (true) { lastObj = (T) inReader.readObject (); System.out.println (lastObj.getClass ().getName ()); if (null != lastObj) {

Generics and ReadObject

◇◆丶佛笑我妖孽 提交于 2020-01-14 01:36:11
问题 I have a simple server that uses generics and object serialization. (T is the input format, U is the output format). A simplified version that only deals with input is shown below: public class Server <T, U> implements Runnable { @override public void run () { try (ObjectInputStream inReader = new ObjectInputStream (this.connection.getInputStream ())) { T lastObj; while (true) { lastObj = (T) inReader.readObject (); System.out.println (lastObj.getClass ().getName ()); if (null != lastObj) {