Category Archives: Socket Programming

Socket programming tutorials in C, Python, Perl, Php, Java and Winsock

Browse Sub-Categories:

UDP Socket programming in winsock – How to code Client and Server

By | July 29, 2020

UDP sockets UDP stands for User Datagram Protocol and is an alternative protocol to TCP the most common protocol used for data transfer over the internet. UDP is different from TCP in a number of ways. Most importantly UDP is a connectionless protocol. TCP vs UDP In the TCP protocol first a connection is established… Read More »

Programming UDP sockets in C on Linux – Client and Server example

By | July 31, 2020

UDP sockets This article describes how to write a simple echo server and client using udp sockets in C on Linux/Unix platform. UDP sockets or Datagram sockets are different from the TCP sockets in a number of ways. The most important difference is that UDP sockets are not connection oriented. More technically speaking, a UDP… Read More »

Receive full data with the recv socket function in python

By | August 7, 2012

In an earlier article we saw how to send and receive data in python using sockets. Lets take a quick example : #Socket client example in python import socket #for sockets import sys #for exit #create an INET, STREAMing socket try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) except socket.error: print ‘Failed to create socket’ sys.exit() print ‘Socket… Read More »

Java socket programming Tutorial – How to code Client and Server

By | July 31, 2020

Socket programming in Java This is a quick guide/tutorial to learning socket programming in Java. The Socket class is documented at http://docs.oracle.com/javase/1.4.2/docs/api/java/net/Socket.html To summarise the basics, sockets are the fundamental “things” behind any kind of network communications done by your computer. For example when you type www.google.com in your web browser, it opens a socket… Read More »

PHP Socket programming Tutorial – How to code Client and Server

By | July 29, 2020

Php and tcp/ip sockets This is a quick guide to learning socket programming in php. Socket programming php is very similar to C. Most functions are similar in names, parameters and output. However unlike C, socket programs written in php would run the same way on any os that has php installed. So the code… Read More »

C program to get ip address from interface name on Linux

By | March 17, 2012

Interface name is something like “eth0” and the ip address of the interface can be retrieved using the ioctl function. Here is a simple piece of code that demonstrates how : Code #include <stdio.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/ioctl.h> #include <netinet/in.h> #include <net/if.h> #include <unistd.h> #include <arpa/inet.h> int main() { int fd;… Read More »