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 7912481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:37:01+00:00 2026-06-03T13:37:01+00:00

I am trying to write a very simple unix domain datagram client/server. Here is

  • 0

I am trying to write a very simple unix domain datagram client/server.

Here is the python server:

import socket,os

s = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
try:
    os.remove("/tmp/socketname")
except OSError:
    pass
s.bind("/tmp/socketname")
while 1:
    data = s.recv(1024)
    print data

conn.close()

and here is a python client that seems to work just fine with the server

import socket
import time

sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
sock.sendto('Hello, world', "/tmp/socketname")
sock.close()

The purpose of this exercise was to play with boost::asio networking library, the python code just makes the server simple with a simple client to prove(-ish) that the server is working.

I am having some issues with the C++ client:

#include <boost/asio.hpp>

int
main(void)
{
    const pid_t pid = getpid();
    boost::asio::io_service my_service;
    const boost::asio::local::datagram_protocol::endpoint ep("/tmp/socketname");
    boost::asio::local::datagram_protocol::socket my_sock(my_service);

    //my_sock.connect(ep);
    //my_sock.send(boost::asio::buffer(&pid, sizeof(pid)));
    my_sock.send_to(boost::asio::buffer(&pid, sizeof(pid)), ep);

    return 0;
}

If I comment out the 2 lines that use connect/send the seems to work. But the the line which uses send_to fails with the following error.

terminate called after throwing an instance of ‘boost::exception_detail::clone_impl >’
what(): Bad file descriptor
Aborted

Thanks for any and all help provided.

  • 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-06-03T13:37:02+00:00Added an answer on June 3, 2026 at 1:37 pm

    You’ve never opened the socket by calling open(), or any of the other methods that open it automatically, such as connect().

    int
    main(void)
    {
        const pid_t pid = getpid();
        boost::asio::io_service my_service;
        const boost::asio::local::datagram_protocol::endpoint ep("/tmp/socketname");
        boost::asio::local::datagram_protocol::socket my_sock(my_service);
    
        //my_sock.connect(ep);
        //my_sock.send(boost::asio::buffer(&pid, sizeof(pid)));
        my_sock.open();
        my_sock.send_to(boost::asio::buffer(&pid, sizeof(pid)), ep);
    
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For fun I'm trying to write a very simple server in C. When I
I'm trying to write a very simple Python utility for personal use that counts
I am trying to run a very simple server/client ssl code with a self
I'm trying to write a very simple email script in python. It's basically a
I am trying to write a VERY simple UI in Python using Tkinter. I
I am trying to write a very simple RSS channel which would display the
I'm trying to write a very simple image processing program for fun and practice.
I'm trying to write a very simple program, I want to print out the
I am trying to write a very simple method to remove duplicates in a
I'm trying to write something very similar to an IM client (for learning purposes

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.