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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:32:12+00:00 2026-05-28T06:32:12+00:00

what could be best way to implement observer pattern when I use 2 programming

  • 0

what could be best way to implement observer pattern when I use 2 programming languagues C and Java? It’s not necessarily use observer patter I just need to know how to implement method or function like notifyall() to notify both clients which are connected to session after action of one client. Its enough to just send them string message.

I have server application in C and clients in Java swing.
There are n games on server, to each game can be connected two clients.
server and client use sockets with Inet Address and server and client have 2 metods – send, recieve.
I have realized:
server – C :
– send – send message to client (client is specified by socket file descriptor)
– recieve – recieve message from client (client is specified by socket file descriptor)
client – in Java
– send – send message to server (server is specified by socket file descriptor)
– recieve – recieve message from server (server is specified by socket file descripor)

Server runs on localhost 127.0.0.1 and port for example 10000
Clients too. I connect clients to server adress 127.0.0.1, port 10000.

Message is simple string like “Hello world\n”
1. run server, server wait for messages
2. run client – client send message to server
3. server – recieve message and send message back to client
server proccess the each client in new process using fork
server and client write sent and recieved messages
4.client end after sent message

this is what work.

I have class in java swing which represents client GUI, there are n buttons(JButton), for example 16, each of them have image icon, each button have added ActionListener
if I click on the button something should happen – change or not to change the ImageIcon.

What I’m trying to implement is method something like observer

I need somehow have something like sessions on server:(which represents games)
game1: client1, client2
game2: client3, client4
game3: client5, client6
etc..
1.I press button number 15 in client1, client send to server message like “client1 pressed button no. 15”
2. Server recieve message and send message like “client1 pressed button 15” to all clients conencted in game1 (client1, client2). In server message will be also if is necessarilly something like “change ImageIcon of button 15”.
point number 2 should be function notifyAll
What is good and simple way to implement it?

Thanks for advices.

  • 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-28T06:32:13+00:00Added an answer on May 28, 2026 at 6:32 am

    You simply need a “list” of clients to “notify”

    The “list” could be as simple as an array of hostnames or IP addresses.

    Your “event” handler would just iterate through the list, sending a message to each host in turn.

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

Sidebar

Related Questions

Just wondered if anyone could give me some advice on the best way to
What's the best way to implement a stack using linked lists in Java? EDIT:
I wonder if anyone could suggest the best way of looping through all the
Could someone please explain the best way to connect to an Interbase 7.1 database
Could anyone guide me as to the best way to upload a collection of
What would be the best way to resize images, which could be of any
I was wondering if someone could tell me the best way to call a
How could I best implement the following scenario? I have a Next Period... button
What's the best way to implement an Android Market-like tabbar (Apps/Games/Downloads)? It would be
What is the best way to implement an interface that combines some instances of

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.