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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:47:03+00:00 2026-05-29T21:47:03+00:00

I am working on a very simple app that needs to listen on a

  • 0

I am working on a very simple app that needs to listen on a designated port for incoming UDP messages, and then display them in a GTK Entry field. I am trying to work from the GSocket documentation, but not having much luck.

Below are my related functions (error checking left out). I call open_listen_socket from main, and then launch a timeout which calls get_incoming_messages every second or so. The first time get_incoming_messages is called, the app crashes with a Segmentation fault.

I don’t know if I’m just missing something dumb, or if I’m on completely the wrong track with my usage of the GSocket for listening, but any guidance will be greatly appreciated. I’ve been on a short deadline and you guys have been saving my butt the past few days!!

static void open_listen_socket()
{

GInetAddress *localAddress;
GSocketAddress *localSocketAddress;


localAddress = g_inet_address_new_from_string("127.0.0.1");
guint16 listenPort = atoi(gtk_entry_get_text (GTK_ENTRY (listenPortField)));

localSocketAddress = g_inet_socket_address_new(localAddress, listenPort);

listenSocket = g_socket_new(G_SOCKET_FAMILY_IPV4, G_SOCKET_TYPE_DATAGRAM, 17, NULL);

g_socket_bind (listenSocket, localSocketAddress, FALSE, NULL);



}

static void get_incoming_message()
{

gchar *buffer=NULL;
gsize size=100;

g_socket_receive(listenSocket, buffer, size, NULL, NULL);

if (strlen(buffer) > 0)
{
    gtk_entry_set_text (GTK_ENTRY (current_status_message_box), buffer);
}


}
  • 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-29T21:47:05+00:00Added an answer on May 29, 2026 at 9:47 pm

    Without looking at the docs, the call to g_socket_receive looks bogus. The buffer arg is null – what is the function meant to do with that (it could mean it will allocate its own buffer). Are you sure it isn’t mean to be &buffer?

    < edit>

    Nope, it’s a char* that is supposed to be allocated with at least size bytes. Yours is null. that will do it.

    < /edit >

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

Sidebar

Related Questions

I'm working on a very simple iPhone app, that in the end will have
I've been working on a gui app that needs to manage external processes. Working
I'm in lean startup mode, working on a simple phone app that will be
I'm working on an app which takes in a raw binary message (very simple,
I'm working on an augmented reality app for iPhone that involves a very processor-intensive
I'm working on a very simple email-like messaging functionality as part of an App
I am a newbie working in a simple Rails app that translates a document
I'm working on a very simple web app, written in Go language. I have
I am working on creating a very simple app. 2 buttons, both play sound.
I'm working on a very simple game (essentially an ice sliding puzzle), for now

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.