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

  • SEARCH
  • Home
  • 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 466609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:29:51+00:00 2026-05-12T23:29:51+00:00

I am working on Ubuntu 9.04. I am running this on VMware workstation. Here

  • 0

I am working on Ubuntu 9.04. I am running this on VMware workstation. Here is my C code:

int sockfd,cnt,addrlen;
const int on = 1;
struct sockaddr_in servaddr,cliaddr;
char reply[512];

sockfd = socket(AF_INET, SOCK_DGRAM, 0);

if (sockfd < 0) {
   perror("socket");
   exit(1);
}

setsockopt(sockfd,SOL_SOCKET,SO_REUSEADDR, &on,sizeof(on));
bzero(&cliaddr, sizeof(cliaddr));
cliaddr.sin_family = AF_INET;
cliaddr.sin_addr.s_addr = htonl(INADDR_ANY);
cliaddr.sin_port = htons(68);
addrlen = sizeof(servaddr);

if (bind(sockfd, (struct sockaddr *) &cliaddr, sizeof(cliaddr)) < 0) {        
  perror("bind");
  exit(1);
} 

while(1)
{       
   cnt = recvfrom(sockfd, reply, sizeof(reply), 0,(struct sockaddr *) &servaddr, &addrlen);

   if (cnt < 0) {
     perror("recvfrom");
     exit(1);
   } 

   printf("\nReply Received\n");
}

I run this program in one terminal and run ‘dhclient’ on another. I receive no datagrams. What am I doing wrong?

  • 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-12T23:29:51+00:00Added an answer on May 12, 2026 at 11:29 pm

    Looks like you’re listening on UDP port 68 for a broadcasted message from the client? If I’m reading DHCP correctly, the client will send its broadcase ‘discover’ request FROM UDP port 68, but TO UDP port 67 on the server, so you would need to be listening on port 67 to receive it.

    An easy ‘first’ test to test you’re code before trying it with dhclient would be to try talking to your server with netcat. a command line like

    echo "Foo" | netcat -u localhost 68
    

    Should cause a packet to be received by your current code.

    Another good debugging tool is wireshark which will let you see exactly what UDP packets are being sent by dhclient and what they contain.

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

Sidebar

Related Questions

I have an mp3 encoding server running on Ubuntu (natty). This has been working
I am currently running the latest version of Code-blocks in Ubuntu 11.04. I have
I am running Ubuntu 10.04. Whenever I run make clean , I get this:
Cheers all. I'm running Ubuntu 10.04 and the latest Google AppEngine SDK. I'm working
I am working a LAMP web app running on Ubuntu 11.10. I followed instructions
I'm trying to get smartgit running on Ubuntu, and I'm constantly getting this error:
I'm running Ubuntu. My Apache2 default file looks like this: <VirtualHost *:80> ServerAdmin webmaster@localhost
I have ELDK-3.1 installed in a Ubuntu box working perfectly. In another machine, running
Iam working on Ubuntu.(Linux) I want to redirect from the page one.php to two.php,
I am working on ubuntu OS,I have started working on pentaho-BI using eclipse.. Just

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.