-1

I am studying socket concept. As far as I learned socket is like electrical socket that is created in both end of communicating devices (or processes). Socket can keep itself alive forever to listen some request (this is may be the key concept to make any server program).

However, my curious mind wants to know that is it possible to communicate between two computers without creating any socket (file descriptor) ?

Please help with detail description, I am new in this area.

Thank you in advance!

Shamim
  • 101
  • 6

2 Answers2

2

A socket is a standardized programming interface only. In theory one could work directly to the network card (and libraries like DPDK do this) but using the socket API makes it much easier and independent of the specific hardware and network setup.

Steffen Ullrich
  • 13,227
  • 27
  • 39
  • Without socket can I make a port always listen for any request ? – Shamim Mar 12 '20 at 12:47
  • @Shamim: The concept of `listen` is from the socket API. With things like DPDK you interact directly with the network card (read from and write to the card) and then you have to implement IP, TCP etc within your application (user space network stack). – Steffen Ullrich Mar 12 '20 at 12:53
  • If you communicate directly via this library this is not TCP/IP. And the OP ask for TCP/IP – Romeo Ninov Mar 12 '20 at 12:58
  • Don't mind at my frequent question. Does http protocol need to create sockets in both end ? That means, If any data is sent via http protocol then sockets are created also ? – Shamim Mar 12 '20 at 13:13
  • @RomeoNinov: TCP/IP is the protocol on the wire. If you use DPDK with a user space network stack you still use TCP/IP. – Steffen Ullrich Mar 12 '20 at 16:00
  • @Shamim: Again, socket is the common API only. HTTP, TCP, IP... are protocols which can be used with this API and can also be used without this API - but the common socket API makes it much easier. – Steffen Ullrich Mar 12 '20 at 16:02
0

To recieve packets any computer with NIC card, one needs only Layer-2 Mac destination address. Hence Is it actually possible to send some data to remote destination over tcp/ip without any socket?

[Answer] yes, send your packet with the destination MAC address as the desired Computer MAC address. The Packet will be received on the NIC without dropping. This is true if the remote destination is the same LAN or can be reached via the VLAN group or connected peer to peer.

Note: if the question was Is it actually possible to send some data to remote destination (not in the same LAN network) over tcp/ip without any socket?

[Answer] No, if the destination (remote target) is not in your network you can not reach the target machine with just MAC address and/or VLAN.

there are 2 options

  1. if the machines are connected via Layer-2 tunnels like MPLS, VxLAN, PPoP you can encapsulate the original packet (Ethernet MAC + Payload)
  2. You can use IP or IP encapsualtion, where a router will identify the IP address to MAC conversion and forward through right part making it reach the destination.

note: DPDK, PF_RING, Netmap, XDP are mechanism to bypass Kernel Stack. Using Kernel Bypass you receive or transmit packets from the NIC. But it will depend upon the actual value of L2/L3 where network switch or router will sent or forward packet in network