Which socket programming is best (TCP/UDP)? [closed] - java

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 9 years ago.
Improve this question
My client program wants to send a huge file to the server and in return the server program returns a double or triple sized file.
My question is, which approach should I use? Either TCP or UDP.

You could utilize FTP (File Transfer Protocol) for your use case.
It is very common and you can use it with java to get or to upload
files to the FTP server.
Also take a look at this question on SO: File upload in Java through FTP
If you still want to implement it yourself, I would recommend using TCP, since it offers you some services:
Ordered data transfer — the destination host rearranges according to sequence number
Retransmission of lost packets — any cumulative stream not acknowledged is retransmitted
Error-free data transfer
http://en.wikipedia.org/wiki/Transmission_Control_Protocol#Data_transfer

This question is too broad, but the answer is probably TCP; if you're needing to transfer a file, TCP provides ordering and retransmission services that UDP doesn't, and there's no reason to reinvent the wheel.
Along those lines, though, why reinvent HTTP? This sounds like a classic case for using a Web server.

UDP programmin but it will be difficult to implement

Related

How to write a C or Java application to handle TCP SYN requests [closed]

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.

What is needed to make a packet capture system? [closed]

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

Best way to transmit data between two applications [closed]

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 6 years ago.
Improve this question
What is the best way to transmit data between two (Java) applications running on the same machine? One obvious idea would be to use standard Sockets but this doesn't feel right.
I've heard that most operating systems have a built-in system specifically for this task. How is it called and how does it work?
And is there any other good method to do something like that?
I think it depends on what you want to communicate between the applications and the size of your project. Some examples:
Sharing of state - use a database, files or similar
Messaging - use a socket. On top of a socket you have several technologies you can leverage, like HTTP/REST, but you can also create your own transport
There are also message applications you can leverage, like RabbitMQ

Best way of client server communication in Java [closed]

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.

Socket-based communication is independent of a programming language used for implementing it. How is it possible? [closed]

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!!

Categories