how to make an exchange of messages between two different computers in the same network? - jolie

How can have the simple exchange of message between two different computer
code of interface is:
interface MyInterface{
RequestResponse: Doppio(int)(int)
}
code of client is:
include "MyInterface.ol"
include "console.iol"
outputPort B {
Location: "socket://192.168.1.145:8000"
Protocol: http
Interfaces: MyInterface
}
main{
Doppio#B(5)(response);
print#Console(response)()
}
code of server is:
execution { concurrent }
include "MyInterface.ol"
inputPort B {
Location: "socket://192.168.1.145:8000"
Protocol: http
Interfaces: MyInterface
}
main {
Doppio(x)(Dop)
{
Dop=x*2
}
}
the code works because is the same PC and same IP address, but with 2 PC (with their IP address) doesn't work!
for me the problem is the socket but I don't know, help me please

In order to provide a temptative answer, I need to know, at least, two things:
basic network setup;
error message from the execution of the commands jolie server.ol and jolie client.ol.
Tip: pick an IP address of a different device connected to the same network, such as 192.168.1.xxx, and provide the result of ping 192.168.1.xxx. Also, the network/firewall should allow for incoming connections to the port you would choose (for instance 8000, as in the code snippet above).

Related

Telnet Port connectivity from one server to another through JSP

Hi All,
I want to create a JSP page where I will ask user to give the source host and port and also destination host and port.
Following combination of source and destination OS is possible
Unix->Unix/Windows/zOS Windows-> Unix/Windows/zOS zOS ->
Unix/Windows/zOS
With these inputs I want to connect to the source server and fire this command telnet $ip $port to the destination. If the telnet connectivity is successful it should return success and else error.
I want to create the logic non-interactive that it should not require any password to login the source for checking telnet connectivity.
Is there any such library or any mechanism available so that I could make this feasible?
Why not use Apache Commons Net?
TelnetClient telnet = new TelnetClient();
try {
telnet.connect("rainmaker.wunderground.com", 3000);
} catch(IOException e) {
// failed
} finally {
telnet.disconnect();
}

Select IP Addresses which use a specific port

My idea here is create a website where the user is able to click a button which will look into the IP Addresses to see which one is using a certain port, for example:
I want to search for the IP Addresses which are communicating with the localhost that are using the port #3620 (which is obviously being used) and a code will show all the IP Addresses.
My question here is to see if this is possible and if it is, can someone give a brief idea of how this could be done?
For seeing if a port is open check out this:
In C#, how to check if a TCP port is available?
You could even loop over all port numbers for an IP address and check to see what ones are open.
TcpClient tcpClient = new TcpClient();
try
{
tcpClient.Connect("127.0.0.1", 9081);
Console.WriteLine("Port " + 9081+ " Open");
}
catch (Exception)
{
Console.WriteLine("Port " + 9081+ " Closed");
}

Cannot get simple SignalR Azure worker role to work

I am trying to get a simple WebSocket server going using SignalR, OWIN and Azure Worker Roles.
WorkerRole.cs:
public class WorkerRole : RoleEntryPoint
{
public override void Run()
{
string url = "http://" + RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["MyEndpoint"].IPEndpoint;
using (WebApp.Start<Startup>(url))
{
Trace.WriteLine(String.Format("Server running on {0}", url));
}
while (true)
{
}
}
/* ... */
}
Startup.cs:
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.MapSignalR();
}
}
MyHub.cs:
public void Send(string name, string message)
{
Clients.All.addMessage(name, message);
}
The Endpoint "MyEndpoint" is defined in the Service as http, public and private port 5001.
After starting the service, it shows up under Azure Compute Emulator as running on 5001. However, if I try to connect to ws://127.0.0.1:5001/signalr (or just ws://127.0.0.1:5001) there is no response. I am using two different web socket clients for this purpose (both are Chrome plugins and they both worked fine using other WebSocket servers).
Questions:
1) Is there anything obviously wrong with my setup?
2) Do I need to use the SignalR JS client libraries to connect to the SignalR server, or should any vanilla client implementing the WebSocket protocol be able to connect?
I know this is a bit of an old post but just in case someone needs it...
1) There are two problems you need to address.
First of all, Start method in:
using (WebApp.Start<Startup>(url))
{
Trace.WriteLine(String.Format("Server running on {0}", url));
}
returns an IDisposable (hence the using(...){} block) means it is immediately disposed after creation since execution continues right passed Trace.Writeline(...) without pause.
It's also a bit tricky running these things under the Azure Compute Emulator for a few reasons, mainly because it remaps ports to avoid collisions. If you open up a command prompt and run
netstat -a
you'll find that you have open ports (listening) looking something like this (in my case I'm using port 81):
TCP 127.0.0.1:82 MyComputer:0 LISTENING
TCP 127.0.0.3:81 MyComputer:0 LISTENING
In the general console ouput of Visual Studio, you'll also most likely see something like
"Windows Azure Tools: Warning: Remapping private port 81 to 82 in role 'MyRoleThingy' to avoid conflict during emulation."
This all means that in order to connect to the server you're hosting using your worker role, you'll have to connect to port 82 instead of 81 (probably 5002 in your case).
2) If you implement the protocol, anything should work I think. Managing an initial connection on the port should always work.

Distinguish forwarding traffic and locally originated traffic in Linux network driver

Is there any information in the struct skbuff to distinguish between the forwarding traffic (bridge forwarding and ip forwarding) and locally originated traffic? We want to treat these two kinds of traffic differently in the network driver because the forwarding traffic do not require cache invalidation on the whole packet size.
Any suggestions are appreciated. Thank you very much!
Yes it's possible, you can try to follow the life cycle of a receiving packet by looking at all calls from this function ip_rcv_finish (http://lxr.free-electrons.com/source/net/ipv4/ip_input.c?v=3.3#L317).
The struct struct sk_buff contain a pointer to the destination entry :
struct dst_entry *dst;
which contain a function pointer :
int (*input)(struct sk_buff*);
to call for the input packet, in the case of local packet the kernel call ip_local_deliver function and for the forwarding packet it calls ip_forward function.
I think that you can, check like this for local and forwarded packets:
- Local :
/* struct sk_buff *skb : Entry packet */
if (((struct rtable *)skb->dst)->rt_type == RTN_LOCAL)
{
/* This packet is to consume locally */
}
- Forward :
if (((struct rtable *)skb->dst)->rt_type == RTN_UNICAST)
{
/* This packet will be forwarded */
}

Set preferred listen address in weblogic 11g

I have a WebLogic 11g domain with 1 admin server and 4 managed servers running on 2 machines. Each machine has 3 ip addresses, but only one of those addresses is seen by another machine. Each machine is running a node manager which seems to communicate fine between each other and admin server. Though when managed server starts on the second machine it can't communicate to admin server because it uses wrong ip address. It appears that when weblogic starts it maps itself to all ip addresses, but selects wrong one as the first one i.e. default. That's why managed servers recieve wrong information from node manager.
Is there a way to set preffered listen address in weblogic 11g, but still allow it to listen to all other addresses either? How does weblogic get list of ip addresses? Is the order of them OS-dependent?
Does this answer the question? I believe if you play with the scripts in /etc/sysconfig, you'll affect the loading order and thence the enumeration order. I must admit, I don't have a RH box here to confirm that suspicion.
Weblogic uses the NetworkInterface.getNetworkInterfaces() method and his own logic to set the order of the listen addresses. This logic is changed from 10.3.2 to 10.3.4.
The relevant code is in the method getAllAddresses of the class weblogic.server.channels.AddressUtils$AddressMaker in weblogic.jar
You can check the order with a simple test:
import java.net.*;
import weblogic.server.channels.*;
public class TestIP_WLS {
public static void main(String args[]) throws UnknownHostException {
System.out.println("=== AddressUtils.getIPAny()");
InetAddress addrs[] = AddressUtils.getIPAny();
for (InetAddress addr : addrs) {
System.out.println("*** " + addr);
}
}
}

Resources