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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:37:31+00:00 2026-06-12T08:37:31+00:00

I was given this sample code from college today and it worked fine inside

  • 0

I was given this sample code from college today and it worked fine inside the college but when I run it (using Eclipse) on my home machine I get permission denied. The machine in college is Windows (7) and my computer at home is Linux (Ubuntu).

Why am I getting the following error?

Error in I/O
Permission denied

I’m using port 338.

Copy of the code :

import java.io.*;
import java.net.*;
import java.util.*;

public class Server 
{
    public static void main(String[] args)
    {
        try
        {
            // First create the input from the keyboard
            BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
            System.out.println("Server Program");

            // Get the port to listen on
            System.out.print("Enter port number to listen on: ");
            String port_string = input.readLine();

            // The port number needs to be an int, so convert the String to an int
            int port = Integer.parseInt(port_string);

            // Create a ServerSocket to listen on this address
            ServerSocket server = new ServerSocket(port);

            // Accept an incoming client connection on the server socket
            Socket sock = server.accept();

            // Create the output stream to the client
            DataOutputStream network = new DataOutputStream(sock.getOutputStream());

            // Send message
            network.writeUTF("Welcome " + sock.getInetAddress().getHostName() + ". We are " + new Date() + "\n");

            // Close sockets.  This will cause the client to exit
            sock.close();
            server.close();
        }
        catch (IOException ioe)
        {
            System.err.println("Error in I/O");
            System.err.println(ioe.getMessage());
            System.exit(-1);
        }
    }
}
  • 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-12T08:37:32+00:00Added an answer on June 12, 2026 at 8:37 am

    Ports under 1024 are on most modern OS’s (Ubuntu included) privileged, and require you to run the program as administrator/root or with elevated privileges.

    Try a higher port for testing at home and you should be ok.

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

Sidebar

Related Questions

Given this sample code: #include <iostream> #include <stdexcept> class my_exception_t : std::exception { public:
I'm doing triangle to AABB intersection tests, and I'm taking this sample code from
I have this snippet from apple sample code LazyTableImages . In the code below
I try to bring this sample to run http://wiki.restlet.org/docs_2.0/13-restlet/275-restlet/252-restlet.html but once I start it
in java i tried using getComponentAt(x, y) method from container class. but for given
I have written a code from the answer given here My sample code is
Given this 3D bar graph sample code , how would you convert the numerical
For one or another reason this code sample gives 48 hours instead of 24,
This should be a simple one, but I'm a beginner with C#. Given a
Given this code: List<Integer> ints = new ArrayList<Integer>(); // Type mismatch: // cannot convert

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.