Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 641815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:06:13+00:00 2026-05-13T21:06:13+00:00

Sorry for a very generic sounding question. let’s say #include <sys/socket.h> #include <sys/types.h> #include

  • 0

Sorry for a very generic sounding question.

let’s say

#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>


#define SERVER_ADDRESS  "123.456.789.012"
#define CLIENT_ADDRESS  "123.456.789.013"

#define SERVER_TCP_PORT "1234"
#define CLIENT_TCP_PORT "1235"


int main()
{
    printf("o halo thar");


    int sockfd, new_sockfd, msg_len;
    void * got_msg = "got ur msg!";
    void * message;
    struct sockaddr_in server_address, client_address;


    if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0 )
        exit(1);
    printf("socket is opened");

    bzero((char * ) &server_address, sizeof(server_address)); 
    server_address.sin_family = AF_INET;
    server_address.sin_addr.s_addr = htonl(SERVER_ADDRESS);
    server_address.sin_port = htons(SERVER_TCP_PORT);


    if (bind(sockfd, (struct sockaddr *) &server_address, sizeof(server_address)) < 0)
        exit(1);
    printf("socket is bound");

    listen(sockfd,11);
    printf("listening");

    if (accept(sockfd, (struct sockaddr *) &client_address, sizeof(client_address)) < 0) // THE BAD LINE 
        exit(1);
    printf("accepted"); 

    int i;
    for( i = 0; i < 11; i++)
    {
        msg_len = recv(sockfd, (void *) message, 10000, 0);
        if (msg_len < 1)
            exit(1);
        printf("receiving msg");

        if (send(sockfd, (void *) got_msg, 10000, 0) < 0);
            exit(1);
        printf("sending msg");
    }

    close(sockfd);

}

it should print abc if everything runs correctly. of course, my code doesn’t. but i have localized the problem to this certain line of code which i’m calling somecode(). when i comment out somecode(), the program prints out ab (not c). however when not commented out, it prints nothing. so what kind of problem am i running into that affects previous statements? sorry for the vagueness. i’m just wondering how seeing somecode() is compiled fine, but when running, it influences executions of code that should be done before it reaches somecode()? Thanks guys.

EDIT:somecode() being

   if (accept(sockfd, (struct sockaddr *) &client_address, sizeof(client_address)) < 0)
      exit(1);

EDIT2:
sorry for being too vague. i even forgot to describe what happens to the program. it doesn’t print anything out and i have to ctrl+c in order to get out of it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:06:13+00:00Added an answer on May 13, 2026 at 9:06 pm

    What happens if you fflush(STDOUT) after each call to printf? Maybe your program is dying before printing all buffered output.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 533k
  • Answers 533k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Looks like it was an IIS installation thing - found… May 17, 2026 at 12:26 am
  • Editorial Team
    Editorial Team added an answer You can use the SqlConnectionStringBuilder for that: var connectionString =… May 17, 2026 at 12:26 am
  • Editorial Team
    Editorial Team added an answer Using RGB you will have harder times avoiding gray colors,… May 17, 2026 at 12:26 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Sorry to bother - perhaps this is a very simple question - but for
I'm sorry if this is a very simplistic question but I'm still learning the
Sorry for what is a generic title. I'm not the best at titles. Anyway
Well, first of all sorry about this question it must be pretty straight forward
Sorry if the title is not very clear. I was not sure about the
Sorry about the title. I do realize it's not very descriptive. :| Here is
First of all, sorry, but my English is not very good. I'm at the
Sorry for totally stupid question, but the situation is that I have to make
Sorry for the bad title, but I have no idea how to put this
Sorry for the long winded title, but the requirement/problem is rather specific. With reference

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.