Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am developing a Java application in which I need to pass details of a Socket object to remotely connected computer through a Socket... I tried it by passing the socket object in object output stream. But as "Socket" is not "serializable" it didn't work...
Can anyone help me please? Or tell me whether it is possible or not...
Thank you...
You have the solution at your hand. If you (the server) have 2 opened sockets, one from A and another from B all you have to do is: What is read from A send it to B and what is read from B send it to A. When socket A or socket B is closed (or has an error) you (the server) close both socket and the conversation is over. To deal with this scenario, you need to use select or another non-blocking mechanism to see which socket has data to be read and act accordingly. I would recommended to use a separate thread to do this job, so the server will be free to attend more clients.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I want to handle TCP SYN requests from users to denied some invalid requests to web server (Apache) on a CentOS server
How to write an application in C++ or Java or any programming languages?
You can create a netfilter kernel module (in C language), and hook yourself for various packet events such as receiving a packet on a particular interface etc. You will need to check the packet header to figure out whether it is a TCP SYN request, and then decide what to do with it.
https://www.netfilter.org/
You cannot create a user mode C++ or Java program to achieve this.
That being the answer for what you are asking, perhaps a better alternative would be to add rules to the firewall depending on what invalid requests you want to disable.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I'm wondering what it would take (skills wise) to make a packet capture system that collects the destination of the packets and stores them, so any help would be appreciated!
I'm hoping to do it in Python or Java, if that helps.
What you're trying to develop already exists for many years, and with multiple implementations:
Wireshark
TCPDump.
Both applications can write the packets in the PCAP format. Bear in mind that these applications require root access and privileges as they ask the kernel to fork the incoming packets to your application.
I Think you need something like jpcap and jNetpcap is wrapping in java.
check out below links :
sniff network traffic in java
full example of network sniffing in java
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I am building an application where in the requirement is that, there is a main server, which will send signal to client server, based on this signal the client performs certain action and send back the response to the main server. Here there will be only one main server and can be multiple client servers. At a given time the main server can send multiple signal to multiple clients.
I am presently planning to do this using socket programming in Java using two ports. Do let me know the best way of achieving this? and also do we have any good existing API's that can be used?
Take a look at RMI: https://docs.oracle.com/javase/tutorial/rmi/ If you want something based on sockets/TCP/UDP/etc, writing something with Netty may be good solution -> http://netty.io/ (they have useful examples).
I would also recommend to consider plain Java Sockets if planned communication beetween server and clients is not comlex and you do not need all this stuff which is provided by libraries like Netty.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I understand that Socket-based Communication is independent between programming languages. Which means, a socket program written in Java language can communicate to a program written in C or C++ socket
program. And I've see many similar questions like mine in Stack overflow and I appreciate those answers.
But I didn't get what I'm looking for. Can anyone answer this with example code as JAVA program as a Server and C++ program as Client which runs on different machine and how they communicate?
Thank You :)
Socket communication is basically sending a set of bits (data/packet as you would call at a higher level) from one port to another. Port is nothing but a file/IO stream that can listen to data or send data given the correct address. A valid address is a combination of valid IP address(depending on if you want local or remote communication) and port number.
To answer your question we basically are opening a file, writing or waiting to be written into from another application. So, file open, close, read, write has nothing to do with a programming language. Only thing that varies between different languages are the APIs or interfaces provided to achieve this purpose.
When you open a socket you mention about the protocol you want to use for this communication, it could be TCP/UDP based on the purpose of your application. The protocol decides how the packet/data being sent and received are ordered. Basically, trying to establish a common ground between the 2 parties trying to communicate.
Hope this answer helps!!
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am wondering if an idea i have in mind is possible in object oriented programming.Let us say i have a client (A) on a certain ip address i.e 192.168.1.105 and a server (B) on ip address 192.168.1.101. Would it be possible to access objects in client (A) and possibly modify an object of my choice on the same client from server (B) ?.Is there a technique in c++ or java or any other major language i can use to achieve this ?.
There are actually several technologies that allow you to do that but I guess you mean language independent CORBA or Java's RMI. Also have a look at remote EJB calls etc.
Once you have sockets opened you can use them to exchange messages between client and server. This messages may be interpreted to do what you need.
E.g.: a message with a known content issued from client to server causes an object on the server side to change!
However, this seems quite obvious, maybe you meant something else (Remote Method Invocation)?