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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:12:39+00:00 2026-06-07T10:12:39+00:00

Okay so I have had a few small problems while sending data over WiFi.

  • 0

Okay so I have had a few small problems while sending data over WiFi. I have a Rabbit RCM5400W WiFi board and I need to send data to it. I have created a few client/server socket examples in Java that have run over localhost port 5000 and have been able to send and receive data. I am now trying to create a program that runs over WiFi that will echo back any information the client (Java) sends the server (Dynamic C). So far all of my connections have either timed out or thrown a “java.net.ConnectException: Connection refused”. Any help to connect these 2 would be appreciated.

Dynamic C Server

     #class auto

     #define TCPCONFIG             1
     #define _PRIMARY_STATIC_IP    "10.10.6.100"
     #define _PRIMARY_NETMASK      "255.255.255.0"
     #define MY_GATEWAY            "10.10.6.1"
     #define MY_NAMESERVER         "10.10.6.1"
     #define IFC_WIFI_SSID         "rabbitTest"
     #define IFC_WIFI_ROAM_ENABLE  1
     #define IFC_WIFI_ROAM_BEACON_MISS  20
     #define IFC_WIFI_CHANNEL      1
     #define IFC_WIFI_MODE         IFPARAM_WIFI_ADHOC
     #define IFC_WIFI_REGION       IFPARAM_WIFI_REGION_AMERICAS
     #define IFC_WIFI_ENCRYPTION   IFPARAM_WIFI_ENCR_NONE

#use "dcrtcp.lib"


#define PORT 5000


void main()
{
int bytes_read;
/*
    Unless STDIO_ENABLE_LONG_STRINGS is defined, printf() has max 127 bytes
    it can output.  For this sample, we'll read in a maximum of 100 bytes
    at a time.
*/
char    buffer[100];
tcp_Socket socket;

// Start network and wait for interface to come up (or error exit).
sock_init_or_exit(1);

while(1) {
    tcp_listen(&socket,PORT,0,0,NULL,0);

    printf("Waiting for connection...\n");
    while(!sock_established(&socket) && sock_bytesready(&socket)==-1)
        tcp_tick(NULL);

    printf("Connection received...\n");

    do {
        bytes_read=sock_fastread(&socket,buffer,sizeof(buffer)-1);

        if(bytes_read>0) {
            buffer[bytes_read]=0;
            printf("%s",buffer);
            sock_write(&socket,buffer,bytes_read);
        }
    } while(tcp_tick(&socket));

    printf("Connection closed...\n");
 }
} 

Java Client

import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import java.util.Scanner;

public class Client implements Runnable {
// The socket connecting us to the server

private Socket socket;
// The streams we communicate to the server; these come
// from the socket
private DataOutputStream dout;
private DataInputStream din;

// Constructor
public Client(String host, int port) {

// Connect to the server
    try {
// Initiate the connection
            socket = new Socket(host, port);
// We got a connection! Tell the world
            System.out.println("connected to " + socket);
// Let's grab the streams and create DataInput/Output streams
// from them
            din = new DataInputStream(socket.getInputStream());
            dout = new DataOutputStream(socket.getOutputStream());
// Start a background thread for receiving messages
        new Thread(this).start();
    } catch (IOException ie) {
        System.out.println(ie);
    }
    //create a variable to hold how many times we send a message
    int counter = 1;

    //continuously accept user messages from console
    while (true) {
        Scanner kb = new Scanner(System.in);
        //we only want to display this message on startup 
        if (counter == 1) {
            System.out.println("Send:");
        }
        processMessage(kb.nextLine());
        counter++;
    }
}

// Gets called when the user types something
private void processMessage(String message) {
    try {
// Send it to the server
        dout.writeUTF(message);     
    } catch (IOException ie) {
        System.out.println(ie);
    }
}
// Background thread runs this: show messages from other window

@Override
public void run() {
    try {
        // Receive messages one-by-one, forever
        while (true) {
           // Get the next message
            String message = din.readUTF();
           // Print it to our text window
            System.out.println("Recieved: " + message);
           //add a new line for user input
            System.out.println("Send:");
        }
    } catch (IOException ie) {
        System.out.println(ie);
    }
   }
 }

Java RunClient Program

public class ClientRun {

public static void main(String[] args) {
    //we will run the client on port 5000, the same as the server
    int port = 5000;
    //create a new client on WiFi Router port 5000
    new Client("10.10.6.100",port);
 }
}
  • 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-07T10:12:42+00:00Added an answer on June 7, 2026 at 10:12 am

    If you get a “connect timeout” that probably means that client-side wasn’t able to get any network packets to the server. If you get a “connection refused” that means the client-side was able to get a packet through, but what ever it got to didn’t have anything listening for new connections.

    In either case, the problem most likely NOT in the Java code, but in your networking setup; e.g. in the way you have configured the WiFi network, the network interfaces, routing and/or firewalls and packet filters … at both ends.

    You should probably start with something simple:

    • Can you “ping” the server from the command line on the client?

    • Can you establish a TCP/IP network connection from the command line; e.g. using telnet or nc to connect to the server port?

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

Sidebar

Related Questions

Okay so this is for a school assignment. I have had no problems doing
Okay, so I have torn what I had down and am rebuilding it, here's
Okay, so I've read some other people have had this problem, but they either
Okay, this is like the 5th time I have had to ask this question,
Okay, this had me occupied for several hours now and still I have no
Okay, I've been struggling with this for a while now. I have a standard
Okay so heres the situation. I have just had to move servers due to
Okay I have a large CRUD app that uses tabs with Forms embedded in
Okay I have a series of objects based on a base class which are
okay i have found the way to run a video in a image.... the

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.