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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:14:57+00:00 2026-05-30T13:14:57+00:00

I’m trying to open a socket to a website over the Internet, but can’t.

  • 0

I’m trying to open a socket to a website over the Internet, but can’t. After about a minute, a ConnectException is thrown saying that the operation timed out.

Socket clientSocket = new Socket(InetAddress.getByName("gmail.com"), 25);

My computer is connected to a router, which is connected to the Internet. My router is configured to direct all incoming port 25 data to port 2550 on my local machine (192.168.2.2). So, I thought maybe if I set the “local address” and “local port” parameters on the Socket constructor it might work…but this also gives me an “operation timed out” error.

Socket clientSocket = new Socket(InetAddress.getByName("gmail.com"), 25, InetAddress.getByName("192.168.2.2"), 2550);

I saw this SO question, but was wondering if anyone could shed any more light on the issue. Thanks.

  • 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-30T13:14:59+00:00Added an answer on May 30, 2026 at 1:14 pm

    You are trying to connect to port 25 on gmail.com, but that machine is not an email server. You must first look up the MX record for gmail.com, and then try to connect to one of the delivery servers mentioned in the returned MX record.

    For example, with dig mx gmail.com on my machine, I get:

    ; <<>> DiG 9.3.6-P1-RedHat-9.3.6-16.P1.el5 <<>> mx gmail.com
    ;; global options:  printcmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 34063
    ;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 4, ADDITIONAL: 4
    
    ;; QUESTION SECTION:
    ;gmail.com.                     IN      MX
    
    ;; ANSWER SECTION:
    gmail.com.              1697    IN      MX      30 alt3.gmail-smtp-in.l.google.com.
    gmail.com.              1697    IN      MX      40 alt4.gmail-smtp-in.l.google.com.
    gmail.com.              1697    IN      MX      5 gmail-smtp-in.l.google.com.
    gmail.com.              1697    IN      MX      10 alt1.gmail-smtp-in.l.google.com.
    gmail.com.              1697    IN      MX      20 alt2.gmail-smtp-in.l.google.com.
    
    ;; AUTHORITY SECTION:
    gmail.com.              266895  IN      NS      ns1.google.com.
    gmail.com.              266895  IN      NS      ns2.google.com.
    gmail.com.              266895  IN      NS      ns3.google.com.
    gmail.com.              266895  IN      NS      ns4.google.com.
    
    ;; ADDITIONAL SECTION:
    ns1.google.com.         262525  IN      A       216.239.32.10
    ns2.google.com.         262525  IN      A       216.239.34.10
    ns3.google.com.         262525  IN      A       216.239.36.10
    ns4.google.com.         262525  IN      A       216.239.38.10
    
    ;; Query time: 65 msec
    ;; SERVER: 144.52.10.15#53(144.52.10.15)
    ;; WHEN: Tue Feb 28 14:30:04 2012
    ;; MSG SIZE  rcvd: 295
    

    So try connecting to port 25 on gmail-smtp-in.l.google.com (which is the server with the lowest MX priority number).

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
Seemingly simple, but I cannot find anything relevant on the web. What is 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.