Server Socket only accept from certain IP addresses?

I'm trying to write a Server Socket that listens for connections. But I only want it to accept connections from known IP addresses. If I'm using the code below:
try {
serverSocket = new ServerSocket(myPort);
} catch (IOException e) {
for (;;) { //loop forever
Socket clientSocket = null;
try {
clientSocket = serverSocket.accept();
Is there a way that I can influence the serverSocket.accept() method to make it first check the IP address BEFORE the connection is made? If not, then is it a security vulnerability to do the following code (knownClientAddress is the only IP address I want to accept connections from):
try {
serverSocket = new ServerSocket(myPort);
} catch (IOException e) {
for (;;) { //loop forever
Socket clientSocket = null;
try {
clientSocket = serverSocket.accept();
if (clientSocket.getRemoteSocketAddress() != knownClientAddress)
clientSocket.close();
}

jobocop17 wrote:
what would such an interface look like / example? Would that be sufficient for socket security? Can you spoof the IP when using such a method?He doesn't mean interface in the java type hierarchy sense. He means network interface. Like if your machine is on a LAN, with a 10.0, or 192.168 address AND has a public IP address as well. The IP address can be spoofed no matter where it comes from, but if you're only accepting connections on the NIC that's on your LAN, not from one that's on the WAN, then you may be able to trust all the potential connectors, and not have to worry about filtering the incoming address. The outward facing router should take care of the rest for you, or at the very least, will be better equipped to do so than any code that you could write.

Similar Messages

  • Tried to upgrade os4 to os7 but could not due to "find my iphone" still turned on.   Could not turn off at that stage so set up as new iphone.  Now icloud will only accept past id email address which i no longer have,  but itunes on my phone has my correc

    Tried to upgrade os4 to os7 but could not due to "find my iphone" still turned on. 
    Could not turn it off at that stage so set up as new iphone.  Now icloud will only accept past id email address and password which i no longer have,
    but itunes on my phone has my correct current id and password.  I need to restore my back up from itunes, i did not use icloud.
    Any help please. 
    I did try yesterday but did not realise at that time that itunes had correct apple id.  Hopefully this is a good thing!

    Thank you for your prompt reply.
    I have looked at icloud.com/find numerous times and my iPad is not showing at all (see picture below). As I said I did turn off 'Find My iPhone' on my iPad and then erase all settings and data before taking it to the repair centre.
    The gentleman at the repair centre said that the device won't restore because "Apple thinks that 'Find My iPhone' is still turned on" (I'm repeating what he said).

  • OfficeJet J4550 All-In-One not scanning or copying; only prints from certain sites

    I have a HP Pavillion Slimline 400 and my will not scan or copy, and only prints from certain sites.  I have uninstalled and installed the software driver numerous times and still get a "scanner not working" message.  I have also unplugged and turned off and replugged in the USB and the power cords several times.  Currently, I have uninstalled the printer software, so I have no recognizable printer on my PC.  Help!!

    Hello bran1288,
    Welcome to the HP Forums.
    I see that you are having an issue with scanning and printing from a select few sites.
    I have a few steps that we can try to troubleshoot this issue.
    First off, please make sure that you have the printer power cable connected directly to a wall outlet and not a power bar/strip. Here is a document that uses a LaserJet printer as an example but it is meant for HP products in general. Please click on the following link that explains the Issues when Connected to an Uninterruptible Power Supply/Power Strip/Surge Protector.
    As for printing from web pages, please make sure that you have your firewall or anti virus settings turned down as well as the Pop-up blocker disabled.  If this does not resolve the issue, maybe try another web browser such as Mozilla fire fox or Google Chrome.
    As for the scanning issue,  so I can better assist you, please respond with which Operating System you are running:
    Which Windows Operating System am I running?
    Mac OS X: How Do I Find Which Mac OS X Version Is on My Computer?
    Please write me back when you have time and I will be happy to help.
    Cheers, 
    Click the “Kudos Thumbs Up" at the bottom of this post to say “Thanks” for helping!
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    W a t e r b o y 71
    I work on behalf of HP

  • Mailbox to receive emails only from certain mail addresses with organisation

    Hi
    We are using exchange 2010 in our organisation.  A user has requested to only receive emails from certain users within the organisation.  And if any other users try to email then the email is bounced back.  So in a nut shell only certaion
    individuals can email him with the organisation.
    Is there a cmdlet shell that can be used?  Or is there anything that can be done in Exchange Console.

    Hi,
    You can create a transport rule to achieve this goal. Here is an example for your reference.
    Note: 'reject' and '5.7.10' are custom rejection message and enhanced status code. You can change them to what you need.
    Hope it helps.
    Best regards,
    Amy Wang
    TechNet Community Support

  • How to prevent/allow admin access from certain ip address.

    Hello
    trying to setup the following scenario:
    have a user BOB created in Cisco ACS 4.2
    have several network devices with different management IP addresses  all added in Cisco ACS 4.2
    want to be able to allow BOB to access network devices only if BOB's access request is coming from one ip address 1.1.1.1
    If BOB is trying to access network devices from any other ip addresses, the request should be denied regardless of the fact that BOB has full access to all network devices.
    Is there a way to acomplish this using Cisco ACS 4.2
    Appreciate your input.
    Regards,

    It is actually possible, thanks for your doc reference:
    in ACS setup AAA client user will be allowed to call from
    in ACS setup NAR (devices you want to allow access to);
    create user in ACS
    configure user access in ACS:
         allow access to required NARs
         define IP - based access restrictions
              Permitted calling / point of access locations
                   enter AAA client from which user will call (* for ports and * for ip address)
    Save and test
    In failed attempts you should see Authentication failure code "Users access filtered" when trying to login to NAR devices with new username and from non-permitted calling client/ip address.
    Thanks for you help.

  • Can only print from certain programs. Started suddenly.

    Everything was working just fine and then suddenly I can only print from InDesign and Word. And when I print from InDesign I can't change any settings in the "print" dialog box or the program freezes and crashes. When I try to print from firefox, photoshop, illustrator among others, it freezes and crashes. I have tried uninstalling and reinstalling the print driver and restarting my computer numerous times and the problem persists. (Unless I am not doing it properly) I go into my printer settings and remove the printer then go back in and reinstall it.
    Any thoughts or help is greatly appreciated as this is affecting my ability to do my job efficiently. Thanks so much.

    How is this...
    Date/Time: 2008-06-30 09:39:05 -0600
    OS Version: 10.5.3 (Build 9D34)
    Architecture: i386
    Report Version: 4
    Command: Firefox
    Path: /Applications/Firefox.app/Contents/MacOS/firefox-bin
    Version: 2.0.0.14 (2.0.0.14)
    Parent: launchd [107]
    PID: 82568
    Event: hang
    Time: 5.26s
    Steps: 27
    Process: firefox-bin [82568]
    Path: /Applications/Firefox.app/Contents/MacOS/firefox-bin
    ADDRESS BINARY
    00001000 /Applications/Firefox.app/Contents/MacOS/firefox-bin
    00c20000 /Applications/Firefox.app/Contents/MacOS/libmozjs.dylib
    00ccd000 /Applications/Firefox.app/Contents/MacOS/libxpcom.dylib
    00cd1000 /Applications/Firefox.app/Contents/MacOS/libxpcom_core.dylib
    00d8c000 /Applications/Firefox.app/Contents/MacOS/libplds4.dylib
    00d96000 /Applications/Firefox.app/Contents/MacOS/libplc4.dylib
    00da2000 /Applications/Firefox.app/Contents/MacOS/libnspr4.dylib
    00dd8000 /Applications/Firefox.app/Contents/MacOS/libsmime3.dylib
    00dfd000 /Applications/Firefox.app/Contents/MacOS/libssl3.dylib
    00e27000 /Applications/Firefox.app/Contents/MacOS/libnss3.dylib
    00e99000 /Applications/Firefox.app/Contents/MacOS/libsoftokn3.dylib
    00eee000 /Applications/Firefox.app/Contents/MacOS/libxpcom_compat.dylib
    00f2a000 /Applications/Firefox.app/Contents/MacOS/components/libmyspell.dylib
    012ef000 /System/Library/TextEncodings/Unicode Encodings.bundle/Contents/MacOS/Unicode Encodings
    01604000 /System/Library/Frameworks/CoreAudioKit.framework/Versions/A/CoreAudioKit
    15d65000 /Applications/Firefox.app/Contents/MacOS/libfreebl3.dylib
    16813000 /Applications/Firefox.app/Contents/Plug-ins/PrintPDE.plugin/Contents/MacOS/Prin tPDE
    169f0000 /Applications/Firefox.app/Contents/MacOS/libnssckbi.dylib
    16a35000 /System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugI n.bundle/Contents/MacOS/AudioIPCPlugIn
    16a3e000 /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bun dle/Contents/MacOS/AppleHDAHALPlugIn
    16a55000 /Applications/Firefox.app/Contents/MacOS/components/libspellchecker.dylib
    16dc0000 /System/Library/CoreServices/RawCamera.bundle/Contents/MacOS/RawCamera
    179b5000 /Library/Printers/PPD Plugins/AdobePDFPDE800.plugin/Contents/MacOS/AdobePDFPDE800
    192e5000 /System/Library/CoreServices/Encodings/libSimplifiedChineseConverter.dylib
    1962e000 /Library/Internet Plug-Ins/Flash Player.plugin/Contents/MacOS/Flash Player
    1b341000 /System/Library/CoreServices/Encodings/libTraditionalChineseConverter.dylib
    1e5c7000 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Print.framewo rk/Versions/Current/Plugins/PrintCocoaUI.bundle/Contents/MacOS/PrintCocoaUI
    203ac000 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Print.framewo rk/Versions/A/Plugins/PrintingCocoaPDEs.bundle/Contents/MacOS/PrintingCocoaPDEs
    2048c000 /Library/Printers/Xerox/PDEs/FJN.plugin/Contents/MacOS/FJN
    70000000 /System/Library/Components/CoreAudio.component/Contents/MacOS/CoreAudio
    74400000 /System/Library/Printers/Libraries/libPPDLib.dylib
    78e00000 /System/Library/Printers/Libraries/libLW8Utils.dylib
    ba900000 /System/Library/CoreServices/Encodings/libJapaneseConverter.dylib
    bab00000 /System/Library/CoreServices/Encodings/libKoreanConverter.dylib

  • HT203528 Not receiving mail from certain email address

    hi looking for help here I have 2 email address that where put in the junk but are not , I moved the email address to the inbox but then they stopped even coming threw to the junk?... I then thought if I made up a rule to go to a certain folder for this email address I would be happy with this but even this doesn't work and it's taking some times 4-5 hours for me to revive this email address , the server at there end is fine as they send this email to a group and my hotnail account recives it instantly

    Any error message provided and if so, what?
    Are the message headers available in your account's Inbox mailbox and when selecting a message to view it, the content is not shown?
    Is your account a POP or IMAP account?

  • Seems my 4S will only accept a certain number of Favorite phone numbers.. How to add more????

    Is there a fix for the seemingly fixed number of phone number favorites in my 4s??  I can add a favorite only if I delete an existing favorite.. Thanks, Bruce 233

    Recents is limited to exactly 100 calls, independent of whether they are assigned to a contact or not.  No way to change that.
    You can delete recent calls you don't care about to keep the list from filling up.  Swipe across the call and press the Delete button or use the Edit button, top right.

  • Not receiving mails from certain email addresses

    I am sending & receiving the majority or my mails without any problems but there are a few email address from which I am being sent mails that I am not receiving. They are not being notified that I am not receiving the mails either.
    Could they be blocked on Mobile me? How can I unblock these addresses and retrieve the mail?
    Thanks,

    Yep, that's very typcial of mail from lists...
    In Outlook open the message, click on File/Properties, and you'll see a box labled "Internet Headers".  I usually copy that out and paste it to Notepad to make it easier to read...
    You'll find that there are different addresses in the vairous headers.
    This is NORMAL for some types of list mail.

  • My imessages are only sending from my email address?

    When I send iMessages they always send from my email addess attached to my apple id rather than my phone number.
    When I go to Settings>Messages>Send & Recieve my phone number is in grey and I can't select i!
    Please help!

    Hello gomoll,
    After reviewing your post, it sounds like you want to start a new conversation from a phone number and not an email address. I would recommend that you read this article, it may be able to help the issue.
    The greyed out phone number is under how you can be reached.
    When you start a conversation is another option you can change. 
    iOS and OS X: Link your phone number and Apple ID for use with FaceTime and iMessage - Apple Support
    The telephone number will be dimmed when you view these settings on an iPhone.
    Thanks for using Apple Support Communities.
    Have a nice day,
    Mario

  • Restricting Ip 2 server socket

    I am trying to develop a simple program that has client/server communication. For security reasons I'd like to let only clients from certain IPs be able to connect to server socket.
    I come up with the idea that after a connection is established server checks the IP of the client. Will that simple idea work? The function of the program is simple so I dont want to write a big program.
    New ideas are welcome

    I am trying to develop a simple program that has
    client/server communication. For security reasons I'd
    like to let only clients from certain IPs be able to
    connect to server socket.
    I come up with the idea that after a connection is
    established server checks the IP of the client. Will
    that simple idea work? The function of the program is
    simple so I dont want to write a big program.
    New ideas are welcomeHi,
    I write a program that do this, but in my case, there was only four clients, so, my server has one "IF" for each client's Ip, verifing if the IP is an authorized IP.
    By...

  • Excluding connections from certain hosts in log file

    Is it possible to exclude connections from certain IP addresses from
    getting written into the log on a 5.0 server?
    I have monitoring systems that do frequent health checks by binding to
    the server and it adds lots of lines to my logs (about 14 MB per day)
    that I don't need or care about. I'd like to exclude these connections
    from showing up.
    thanks,
    Gary LaVoy
    [email protected]

    Gary LaVoy wrote:
    Is it possible to exclude connections from certain IP addresses from
    getting written into the log on a 5.0 server?
    I have monitoring systems that do frequent health checks by binding to
    the server and it adds lots of lines to my logs (about 14 MB per day)
    that I don't need or care about. I'd like to exclude these connections
    from showing up.
    No, this is not possible
    What you can potentially do is to use the log file rotation and do something like a grep -v to supress the lines that you don't want in the rotated file that won't be used anymore by the server.
    Regards
    Daniel

  • Banning certain MAC addresses

    I need to block all traffic to/from certain MAC addresses from within a certain VLAN on a 6500 running CatOS. Is there a way to do do per-VLAN MAC-based access-lists?

    The IOS command functional equivalent is "mac access-list extended" Here is a snippet from the IOS command reference that covers the highlights:
    Once you enter the mac access-list extended name command, use the following subset to create or
    delete entries in a MAC-access list:
    [no] {permit | deny} {{src-mac mask | any} {dest-mac mask} | any} [protocol [vlan vlan]
    [cos value]]}
    Reference "Catalyst 6500 Series Cisco IOS Command Reference, 12.2SX" (http://www.cisco.com/en/US/partner/products/hw/switches/ps708/products_command_reference_book09186a0080160cd0.html) page 2-357.

  • Your message wasn't delivered due to a permission or security issue. It may have been rejected by a moderator, the address may only accept e-mail from certain senders, or another restriction may be preventing delivery

    HI,
    We are getting following error message for all users while sending mail to external but we able to receive mail from internet.
    Your message wasn't delivered due to a permission or security issue. It may have been rejected by a moderator, the address may only accept e-mail from certain senders, or another restriction may
    be preventing delivery.

    Hi,
    Please follow Luke and Shelly’s suggestion to check your SPF record and Send Connector configuration. Also you can post the complete NDR message(with NDR status code) here for further analysis.
    If there is any updates, please feel free to let us know.
    Thanks,
    Winnie Liang
    TechNet Community Support

  • The server license allows connections from only 5 unique IP addresses

    Hi All,
    For a project, i did "/Installing Oracle BPEL Process Manager with the
    BEA WebLogic Server/".
    While accessing the BPEL Console from more than 2 machine, i am
    getting the following error message.
    "/The Server is not able to service this request:
    [Server:002621]Connection rejected, the server license allows
    connections from only 5 unique IP addresses./"
    I am running the " /Oracle WebLogic Server 9.2 MP3/" weblogic server,
    which i downloaded from the following oracle internal site.
    /http://www.oracle.com/technology/software/products/ias/bea_main.html/
    I have downloaded the license key from the following location.
    /http://licensecodes.oracle.com/
    /I have updated the license key using the "/UpdateLicense.cmd" /file.
    I manually checked the "/license.bea/" file it got changed
    "/expiration="never"/" mode.
    But still i wasn't able to get rid of the above error message. Still
    the license is not updated to the server.
    Regards,
    Vijay.B

    Hi James,
    Thanks a lot for your answer.
    I tried all the possible way to update the license file, i was able to update the file but the problem was not solved.
    I just tried downloading the software from another location and tried updating the license key and now its working fine, i don't see the issue.
    The below link is where i downloaded the software, you can get the license key also.
    "/http://aseng-wiki.us.oracle.com/asengwiki/display/ASHotPlug/Software+Page+-+Internal+Use/"
    Regards,
    Vijay.B

Maybe you are looking for

  • *** Can't get my text to load as text - still loads as an image

    I have an iWeb site I've done and I'm still having trouble with some of my text being displayed as an image. This is an issue for me because it is slowing down the loading of my site. I have 1 page where I converted the text to Georgian and it loads

  • HT201269 iPod to iPhone connection

    Is it possible to download my music from my iPod directly to my new iphone5 without using iTunes or iCloud? I have a camera adapter that will fit into the iPod that has a USB port on the other side that the cord for the iPhone will plug into.

  • Can existing JSF apps import into JSC

    I have a a number of existing JSF applications that were manually created (JSP,code, etc)musing JSF 1.0 FCS. I have tried to import these into the visual designer JSC to look at how they would display but it seems that the JSF tags are aways stripped

  • How to Re-query a standard form.

    Hi there, There is a need to Requery a standard Service Request Form. When "Launch Workflow" button is pressed, it updates a DFF at the database. After this if we wish to add description in Task Description Field, it throws error "Record updated by a

  • Log Naming

    Hello, When I'm logging and capturing and I save a bunch of clips to one bin, why is it that FCP won't allow me to use the same name of a clip in another bin? Is there a way around this? Changing the reel? Or do I have to open a new project? Thanks,