Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Pure VPN - Up to 27 Months
vgp
Updated:
Yesterday at 8:10 AM
එක පැකේජ් එකයි මාසෙටම Unlimited Internet. තාමත් DATA CARD දාන්න සල්ලි වියදම් කරනවද? අඩුම මිලට අපෙන්.
sayuru bandara
Updated:
Tuesday at 12:30 PM
Ad icon
ඉන්ටර්නෙට් එකෙන් හරියටම සල්ලි හොයන්න සහ Success වෙන්න කැමතිද? 🚀 (E-Money & Success Stories)
siri sumana
Updated:
May 30, 2026
Gemini AI PRO 18 months Offer
Hawaka
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Talk!
C programming prashnayak
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="Hecker" data-source="post: 28201554" data-attributes="member: 580416"><p>server ekak haduwa local host dala .Api server seka start karala </p><p></p><p><span style="font-size: 26px"><strong>Me client</strong></span></p><p>$ nc 127.0.0.1 9001</p><p>Hello from the server Hello world</p><p></p><p><span style="font-size: 26px"><strong>Me Server</strong></span></p><p>$ ./a.out</p><p>Client Connected</p><p>Client has sent : Hello world</p><p></p><p>meka prashnayak nathuwa wada kala. </p><p>Eeth deweni para </p><p></p><p><span style="font-size: 26px"><strong>Me client</strong></span></p><p>$ nc 127.0.0.1 9001</p><p>(UNKNOWN) [127.0.0.1] 9001 (?) : Connection refused</p><p></p><p><span style="font-size: 26px"><strong>Me server</strong></span></p><p>$ ./a.out</p><p>(melo magualak unena)</p><p></p><p>man meka aai compile kala ethakota wada. server eka start karanna kalin compile karannama wenawa eeka hada ganne kohomada?</p><hr /><p>----------------------Code eka---------------------</p><p>#include<stdio.h></p><p>#include<sys/socket.h></p><p>#include<sys/types.h></p><p>#include<netinet/in.h></p><p>#include <arpa/inet.h></p><p>int main()</p><p>{</p><p> int server_socket; //used for creating socket</p><p> int client_socket; //used for accepting connection</p><p> struct sockaddr_in server_addr; // Structure required by the 'bind()'</p><p> char buffer[500] = "Hello from the server";</p><p> char recv_buffer[500];</p><p></p><p> server_socket = socket(AF_INET, SOCK_STREAM, 0); //Creates a TCP Socket</p><p> </p><p> server_addr.sin_family = AF_INET; //Declaring the type</p><p> server_addr.sin_port = htons(9001); //Declaring the port number to listen on</p><p> server_addr.sin_addr.s_addr = inet_addr("127.0.0.1"); //Declaring the host</p><p></p><p> bind(server_socket, (struct server_addr*) &server_addr, sizeof(server_addr)); //Bind server</p><p> listen(server_socket, 5);</p><p> </p><p> client_socket = accept(server_socket, NULL, NULL); //Accept incoming connections</p><p> printf("Client Connected\n");</p><p> send(client_socket, buffer, sizeof(buffer), 0); //Sending data to the client</p><p> recv(client_socket, recv_buffer, sizeof(recv_buffer), 0); //Recv data from the client</p><p> printf("Client has sent : %s", recv_buffer); //Print out the data sent by client</p><p></p><p> close(server_socket); //Close the connection</p><p> return 0;</p><p>}</p><p>------ <span style="font-size: 10px">Post added on [DATETIME="UT"]1664178522[/DATETIME]</span></p></blockquote><p></p>
[QUOTE="Hecker, post: 28201554, member: 580416"] server ekak haduwa local host dala .Api server seka start karala [SIZE=7][B]Me client[/B][/SIZE] $ nc 127.0.0.1 9001 Hello from the server Hello world [SIZE=7][B]Me Server[/B][/SIZE] $ ./a.out Client Connected Client has sent : Hello world meka prashnayak nathuwa wada kala. Eeth deweni para [SIZE=7][B]Me client[/B][/SIZE] $ nc 127.0.0.1 9001 (UNKNOWN) [127.0.0.1] 9001 (?) : Connection refused [SIZE=7][B]Me server[/B][/SIZE] $ ./a.out (melo magualak unena) man meka aai compile kala ethakota wada. server eka start karanna kalin compile karannama wenawa eeka hada ganne kohomada? [HR][/HR] ----------------------Code eka--------------------- #include<stdio.h> #include<sys/socket.h> #include<sys/types.h> #include<netinet/in.h> #include <arpa/inet.h> int main() { int server_socket; //used for creating socket int client_socket; //used for accepting connection struct sockaddr_in server_addr; // Structure required by the 'bind()' char buffer[500] = "Hello from the server"; char recv_buffer[500]; server_socket = socket(AF_INET, SOCK_STREAM, 0); //Creates a TCP Socket server_addr.sin_family = AF_INET; //Declaring the type server_addr.sin_port = htons(9001); //Declaring the port number to listen on server_addr.sin_addr.s_addr = inet_addr("127.0.0.1"); //Declaring the host bind(server_socket, (struct server_addr*) &server_addr, sizeof(server_addr)); //Bind server listen(server_socket, 5); client_socket = accept(server_socket, NULL, NULL); //Accept incoming connections printf("Client Connected\n"); send(client_socket, buffer, sizeof(buffer), 0); //Sending data to the client recv(client_socket, recv_buffer, sizeof(recv_buffer), 0); //Recv data from the client printf("Client has sent : %s", recv_buffer); //Print out the data sent by client close(server_socket); //Close the connection return 0; } ------ [SIZE=2]Post added on [DATETIME="UT"]1664178522[/DATETIME][/SIZE] [/QUOTE]
Insert quotes…
Verification
Payakata winadi keeyak tibeda?
Post reply
Top
Bottom