Multi users in socket access server [on hold] Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election Results Why I closed the “Why is Kali so hard” questionWrapping socket connectionspcap and raw socketPath to unix socketSocket remains ESTABLISHED even if remote process is stoppedMulti processing / Multi threading in BASHHow authentication is done between two nodes in tcp/ip or udp client server socketWhat is the difference between lscpu Socket and networking Socket?Multi-threading with for loopSocket Buffer Size and PerformanceRetrieving the SO_INCOMING_CPU of a UDP Socket?

How to override model in magento2?

Using audio cues to encourage good posture

How much time will it take to get my passport back if I am applying for multiple Schengen visa countries?

Why aren't air breathing engines used as small first stages

Why are there no cargo aircraft with "flying wing" design?

Echoing a tail command produces unexpected output?

Why are Kinder Surprise Eggs illegal in the USA?

At the end of Thor: Ragnarok why don't the Asgardians turn and head for the Bifrost as per their original plan?

Compare a given version number in the form major.minor.build.patch and see if one is less than the other

How widely used is the term Treppenwitz? Is it something that most Germans know?

porting install scripts : can rpm replace apt?

English words in a non-english sci-fi novel

How to align text above triangle figure

Why do we bend a book to keep it straight?

Withdrew £2800, but only £2000 shows as withdrawn on online banking; what are my obligations?

3 doors, three guards, one stone

What is Arya's weapon design?

Using et al. for a last / senior author rather than for a first author

How do I keep my slimes from escaping their pens?

Okay to merge included columns on otherwise identical indexes?

What is Wonderstone and are there any references to it pre-1982?

What would be the ideal power source for a cybernetic eye?

Identifying polygons that intersect with another layer using QGIS?

Apollo command module space walk?



Multi users in socket access server [on hold]



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Community Moderator Election Results
Why I closed the “Why is Kali so hard” questionWrapping socket connectionspcap and raw socketPath to unix socketSocket remains ESTABLISHED even if remote process is stoppedMulti processing / Multi threading in BASHHow authentication is done between two nodes in tcp/ip or udp client server socketWhat is the difference between lscpu Socket and networking Socket?Multi-threading with for loopSocket Buffer Size and PerformanceRetrieving the SO_INCOMING_CPU of a UDP Socket?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








-2















i have a code of socket connecting but i have a problem for how can i access with multiple users to the server , i use a loop for() but i use
"i<2 " but me i need to acces to multiple users no just 2 users.



** Code of Server :



#include <netdb.h> 
#include <stdio.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <arpa/inet.h>
#define MAX 80
#define PORT 8080
#define SA struct sockaddr

// Driver function
int main()

int sockfd, connfd, len,start , end,soport,sokpo;
struct sockaddr_in servaddr,serv_addr;
char ips[2][20];

int portno = 631;
char hostname[30] ;
struct hostent *server;

// socket create and verification
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd == -1)
printf("socket creation failed...n");
exit(0);

else
printf("Socket successfully created..n");
bzero(&servaddr, sizeof(servaddr));

// assign IP, PORT
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
servaddr.sin_port = htons(PORT);

// Binding newly created socket to given IP and verification
if ((bind(sockfd, (SA*)&servaddr, sizeof(servaddr))) != 0)
printf("socket bind failed...n");
exit(0);

else
printf("Socket successfully binded..n");

// Now server is ready to listen and verification

if ((listen(sockfd, 5)) != 0)
printf("Listen failed...n");
exit(0);

else
printf("Server listening..n");

len = sizeof(servaddr);
// Accept the data packet from client and verification
for(int i=0;i<2;i++)
connfd = accept(sockfd, (SA*)&servaddr,&len );
if (connfd < 0)
printf("server acccept failed...n");
exit(0);

else
printf("server acccept the client...n");
strcpy(ips[i], inet_ntoa(servaddr.sin_addr));


// After Display close the socket
close(sockfd);




** Code of Client:



 #include <netdb.h> 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <arpa/inet.h>

#define MAX 80
#define PORT 8080
#define SA struct sockaddr



int main()

int sockfd, connfd;
struct sockaddr_in servaddr, cli;

// socket create and varification
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd == -1)
printf("socket creation failed...n");
exit(0);

else
printf("Socket successfully created..n");
bzero(&servaddr, sizeof(servaddr));

// assign IP, PORT
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = inet_addr("192.168.1.5");
servaddr.sin_port = htons(PORT);

// connect the client socket to server socket
if (connect(sockfd, (SA*)&servaddr, sizeof(servaddr)) != 0)
printf("connection with the server failed...n");
exit(0);

else
printf("connected to the server..n");


close(sockfd);










share|improve this question









New contributor




Rober is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as off-topic by Rui F Ribeiro, Kusalananda Apr 12 at 19:56



  • This question does not appear to be about Unix or Linux within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.
















  • I put your question on hold. We've had discussions on our Meta site regarding C programming questions, and what I gather from these is that even though a question may be about the standard Unix C API, pure C programming questions are off-topic here. If you can reword your question to not be a C debugging question and instead possibly ask about the core issue, multi-user access to sockets, then I believe the question would be possible to reopen (by a moderator or through the review queue).

    – Kusalananda
    Apr 12 at 20:14


















-2















i have a code of socket connecting but i have a problem for how can i access with multiple users to the server , i use a loop for() but i use
"i<2 " but me i need to acces to multiple users no just 2 users.



** Code of Server :



#include <netdb.h> 
#include <stdio.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <arpa/inet.h>
#define MAX 80
#define PORT 8080
#define SA struct sockaddr

// Driver function
int main()

int sockfd, connfd, len,start , end,soport,sokpo;
struct sockaddr_in servaddr,serv_addr;
char ips[2][20];

int portno = 631;
char hostname[30] ;
struct hostent *server;

// socket create and verification
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd == -1)
printf("socket creation failed...n");
exit(0);

else
printf("Socket successfully created..n");
bzero(&servaddr, sizeof(servaddr));

// assign IP, PORT
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
servaddr.sin_port = htons(PORT);

// Binding newly created socket to given IP and verification
if ((bind(sockfd, (SA*)&servaddr, sizeof(servaddr))) != 0)
printf("socket bind failed...n");
exit(0);

else
printf("Socket successfully binded..n");

// Now server is ready to listen and verification

if ((listen(sockfd, 5)) != 0)
printf("Listen failed...n");
exit(0);

else
printf("Server listening..n");

len = sizeof(servaddr);
// Accept the data packet from client and verification
for(int i=0;i<2;i++)
connfd = accept(sockfd, (SA*)&servaddr,&len );
if (connfd < 0)
printf("server acccept failed...n");
exit(0);

else
printf("server acccept the client...n");
strcpy(ips[i], inet_ntoa(servaddr.sin_addr));


// After Display close the socket
close(sockfd);




** Code of Client:



 #include <netdb.h> 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <arpa/inet.h>

#define MAX 80
#define PORT 8080
#define SA struct sockaddr



int main()

int sockfd, connfd;
struct sockaddr_in servaddr, cli;

// socket create and varification
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd == -1)
printf("socket creation failed...n");
exit(0);

else
printf("Socket successfully created..n");
bzero(&servaddr, sizeof(servaddr));

// assign IP, PORT
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = inet_addr("192.168.1.5");
servaddr.sin_port = htons(PORT);

// connect the client socket to server socket
if (connect(sockfd, (SA*)&servaddr, sizeof(servaddr)) != 0)
printf("connection with the server failed...n");
exit(0);

else
printf("connected to the server..n");


close(sockfd);










share|improve this question









New contributor




Rober is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as off-topic by Rui F Ribeiro, Kusalananda Apr 12 at 19:56



  • This question does not appear to be about Unix or Linux within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.
















  • I put your question on hold. We've had discussions on our Meta site regarding C programming questions, and what I gather from these is that even though a question may be about the standard Unix C API, pure C programming questions are off-topic here. If you can reword your question to not be a C debugging question and instead possibly ask about the core issue, multi-user access to sockets, then I believe the question would be possible to reopen (by a moderator or through the review queue).

    – Kusalananda
    Apr 12 at 20:14














-2












-2








-2








i have a code of socket connecting but i have a problem for how can i access with multiple users to the server , i use a loop for() but i use
"i<2 " but me i need to acces to multiple users no just 2 users.



** Code of Server :



#include <netdb.h> 
#include <stdio.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <arpa/inet.h>
#define MAX 80
#define PORT 8080
#define SA struct sockaddr

// Driver function
int main()

int sockfd, connfd, len,start , end,soport,sokpo;
struct sockaddr_in servaddr,serv_addr;
char ips[2][20];

int portno = 631;
char hostname[30] ;
struct hostent *server;

// socket create and verification
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd == -1)
printf("socket creation failed...n");
exit(0);

else
printf("Socket successfully created..n");
bzero(&servaddr, sizeof(servaddr));

// assign IP, PORT
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
servaddr.sin_port = htons(PORT);

// Binding newly created socket to given IP and verification
if ((bind(sockfd, (SA*)&servaddr, sizeof(servaddr))) != 0)
printf("socket bind failed...n");
exit(0);

else
printf("Socket successfully binded..n");

// Now server is ready to listen and verification

if ((listen(sockfd, 5)) != 0)
printf("Listen failed...n");
exit(0);

else
printf("Server listening..n");

len = sizeof(servaddr);
// Accept the data packet from client and verification
for(int i=0;i<2;i++)
connfd = accept(sockfd, (SA*)&servaddr,&len );
if (connfd < 0)
printf("server acccept failed...n");
exit(0);

else
printf("server acccept the client...n");
strcpy(ips[i], inet_ntoa(servaddr.sin_addr));


// After Display close the socket
close(sockfd);




** Code of Client:



 #include <netdb.h> 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <arpa/inet.h>

#define MAX 80
#define PORT 8080
#define SA struct sockaddr



int main()

int sockfd, connfd;
struct sockaddr_in servaddr, cli;

// socket create and varification
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd == -1)
printf("socket creation failed...n");
exit(0);

else
printf("Socket successfully created..n");
bzero(&servaddr, sizeof(servaddr));

// assign IP, PORT
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = inet_addr("192.168.1.5");
servaddr.sin_port = htons(PORT);

// connect the client socket to server socket
if (connect(sockfd, (SA*)&servaddr, sizeof(servaddr)) != 0)
printf("connection with the server failed...n");
exit(0);

else
printf("connected to the server..n");


close(sockfd);










share|improve this question









New contributor




Rober is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












i have a code of socket connecting but i have a problem for how can i access with multiple users to the server , i use a loop for() but i use
"i<2 " but me i need to acces to multiple users no just 2 users.



** Code of Server :



#include <netdb.h> 
#include <stdio.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <arpa/inet.h>
#define MAX 80
#define PORT 8080
#define SA struct sockaddr

// Driver function
int main()

int sockfd, connfd, len,start , end,soport,sokpo;
struct sockaddr_in servaddr,serv_addr;
char ips[2][20];

int portno = 631;
char hostname[30] ;
struct hostent *server;

// socket create and verification
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd == -1)
printf("socket creation failed...n");
exit(0);

else
printf("Socket successfully created..n");
bzero(&servaddr, sizeof(servaddr));

// assign IP, PORT
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
servaddr.sin_port = htons(PORT);

// Binding newly created socket to given IP and verification
if ((bind(sockfd, (SA*)&servaddr, sizeof(servaddr))) != 0)
printf("socket bind failed...n");
exit(0);

else
printf("Socket successfully binded..n");

// Now server is ready to listen and verification

if ((listen(sockfd, 5)) != 0)
printf("Listen failed...n");
exit(0);

else
printf("Server listening..n");

len = sizeof(servaddr);
// Accept the data packet from client and verification
for(int i=0;i<2;i++)
connfd = accept(sockfd, (SA*)&servaddr,&len );
if (connfd < 0)
printf("server acccept failed...n");
exit(0);

else
printf("server acccept the client...n");
strcpy(ips[i], inet_ntoa(servaddr.sin_addr));


// After Display close the socket
close(sockfd);




** Code of Client:



 #include <netdb.h> 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <arpa/inet.h>

#define MAX 80
#define PORT 8080
#define SA struct sockaddr



int main()

int sockfd, connfd;
struct sockaddr_in servaddr, cli;

// socket create and varification
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd == -1)
printf("socket creation failed...n");
exit(0);

else
printf("Socket successfully created..n");
bzero(&servaddr, sizeof(servaddr));

// assign IP, PORT
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = inet_addr("192.168.1.5");
servaddr.sin_port = htons(PORT);

// connect the client socket to server socket
if (connect(sockfd, (SA*)&servaddr, sizeof(servaddr)) != 0)
printf("connection with the server failed...n");
exit(0);

else
printf("connected to the server..n");


close(sockfd);







c socket multithreading






share|improve this question









New contributor




Rober is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Rober is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Apr 12 at 19:39









Rui F Ribeiro

42.1k1484142




42.1k1484142






New contributor




Rober is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Apr 12 at 19:32









RoberRober

1




1




New contributor




Rober is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Rober is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Rober is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




put on hold as off-topic by Rui F Ribeiro, Kusalananda Apr 12 at 19:56



  • This question does not appear to be about Unix or Linux within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.







put on hold as off-topic by Rui F Ribeiro, Kusalananda Apr 12 at 19:56



  • This question does not appear to be about Unix or Linux within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.












  • I put your question on hold. We've had discussions on our Meta site regarding C programming questions, and what I gather from these is that even though a question may be about the standard Unix C API, pure C programming questions are off-topic here. If you can reword your question to not be a C debugging question and instead possibly ask about the core issue, multi-user access to sockets, then I believe the question would be possible to reopen (by a moderator or through the review queue).

    – Kusalananda
    Apr 12 at 20:14


















  • I put your question on hold. We've had discussions on our Meta site regarding C programming questions, and what I gather from these is that even though a question may be about the standard Unix C API, pure C programming questions are off-topic here. If you can reword your question to not be a C debugging question and instead possibly ask about the core issue, multi-user access to sockets, then I believe the question would be possible to reopen (by a moderator or through the review queue).

    – Kusalananda
    Apr 12 at 20:14

















I put your question on hold. We've had discussions on our Meta site regarding C programming questions, and what I gather from these is that even though a question may be about the standard Unix C API, pure C programming questions are off-topic here. If you can reword your question to not be a C debugging question and instead possibly ask about the core issue, multi-user access to sockets, then I believe the question would be possible to reopen (by a moderator or through the review queue).

– Kusalananda
Apr 12 at 20:14






I put your question on hold. We've had discussions on our Meta site regarding C programming questions, and what I gather from these is that even though a question may be about the standard Unix C API, pure C programming questions are off-topic here. If you can reword your question to not be a C debugging question and instead possibly ask about the core issue, multi-user access to sockets, then I believe the question would be possible to reopen (by a moderator or through the review queue).

– Kusalananda
Apr 12 at 20:14











0






active

oldest

votes

















0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

getting Checkpoint VPN SSL Network Extender working in the command lineHow to connect to CheckPoint VPN on Ubuntu 18.04LTS?Will the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayVPN SSL Network Extender in FirefoxLinux Checkpoint SNX tool configuration issuesCheck Point - Connect under Linux - snx + OTPSNX VPN Ububuntu 18.XXUsing Checkpoint VPN SSL Network Extender CLI with certificateVPN with network manager (nm-applet) is not workingWill the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayImport VPN config files to NetworkManager from command lineTrouble connecting to VPN using network-manager, while command line worksStart a VPN connection with PPTP protocol on command linestarting a docker service daemon breaks the vpn networkCan't connect to vpn with Network-managerVPN SSL Network Extender in FirefoxUsing Checkpoint VPN SSL Network Extender CLI with certificate

Cannot Extend partition with GParted The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election ResultsCan't increase partition size with GParted?GParted doesn't recognize the unallocated space after my current partitionWhat is the best way to add unallocated space located before to Ubuntu 12.04 partition with GParted live?I can't figure out how to extend my Arch home partition into free spaceGparted Linux Mint 18.1 issueTrying to extend but swap partition is showing as Unknown in Gparted, shows proper from fdiskRearrange partitions in gparted to extend a partitionUnable to extend partition even though unallocated space is next to it using GPartedAllocate free space to root partitiongparted: how to merge unallocated space with a partition

Marilyn Monroe Ny fiainany manokana | Jereo koa | Meny fitetezanafanitarana azy.