473,770 Members | 6,322 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[sockets] accept



Code:
--------------------

BOOL IsIPRight(char *ip)
{
unsigned long TheIP;

TheIP ip;
TheIP = inet_addr("66.5 5.44.33");

if(TheIP)
{
return TRUE;
}
else
closesocket(myS ocket);
return FALSE;
}

SOCKET WINAPI _accept ( SOCKET s, struct sockaddr FAR* addr, int FAR* addrlen )
{
if (addr && addrlen != 0)
{
char *ip = inet_ntoa (((sockaddr_in* )addr)->sin_addr);

if (ip != NULL)
{
if (IsIPRight(ip))
{
return accept(s,addr,a ddrlen);
}
} else {
return accept(s,addr,a ddrlen);
}
} else {
return accept(s,addr,a ddrlen);
}

return 0;
}

--------------------

What I'm trying to do is check the incoming connections' IP with
IsIPRight(ip) and if it is then return true if its not then return
false - thus if it is then accept connection if its not then reject it
by closing the socket.

But the above isn't working. Need some help :)

--
DarkLotus
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------

Nov 18 '05 #1
0 1124

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5021
by: Rookie | last post by:
Hi, I was writing a simple program using sockets. The program is supposed to be a TCP server that receives a string sent by the client. For this purpose I defined a char array called readString which was initially defined as readString. The program worked fine. I then increased the array size to readString and the accept socket call started giving an error (errno=14;EFAULT). This gave me the impression that the clientAddr structure was...
6
6999
by: Laxmikant Rashinkar | last post by:
Is there any way to use a C# socket in promiscuous mode? Any sample code that shows how this is done? any assistance is much appreciated! thanks LK
0
257
by: jm | last post by:
Thanks. The problem is that after the Accept has completed and the DoSomething() executes, it will not "follow through" unless the While(true) is interrupted and it returns to .Accept again. Vague....I know. I don't know if its because one of the procedures it is calling is a WinAPI or not. Funny thing is that if I put a MessageBox in there that that somehow temporarly breaks the While(true) loop and it works.
3
1501
by: derSchweiz | last post by:
Hi, Experimenting with sockets, and I think I got it half working. I have the following code: Private Sub socket_receive(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Activated Dim bytesRec As Integer Dim i As Integer = 0 Dim data1 As Net.Sockets.Socket = cidServer.Accept() 'this line is
1
15636
by: verge | last post by:
hello everyone! how's it going? like everyone in here im in need of some help and good friendship along the way...take a look at this: //MODIFIED SO IT DEALS WITH WINDOWS FTP USING ACTIVE CONNECTION //IMPORTANT: the logic is NOT complete, the program works only once and disconnects or freeze //One needs to modify or rewrite the program so it is fully functional for LIST and RETR
0
1451
by: rossabri | last post by:
This topic has been addressed in limited detail in other threads: "sockets don't play nice with new style classes :(" May 14 2005. http://groups.google.com/group/comp.lang.python/browse_thread/thread/76d27388b0d286fa/c9849013e37c995b "Subclassing socket" Dec 20 2005 - Jan 14 2006. http://groups.google.com/group/comp.lang.python/browse_thread/thread/391728cd442339c8/c0581b9ee5e7ceaf Briefly, the socket module ("socket.py") provides a...
1
2829
by: opi | last post by:
My blocking TCP server hangs in the Accept method when the client software sometimes gets an error. Are there any ways to stop this blocking in the Accept method so I dont have to restart the server? I would rather not use threading or non-blocking sockets. Using VB.Net 2005.
1
1533
by: Karim | last post by:
Hi, I am working on a c++ project involving sockets and threads and I need to ask a pretty basic question. If you have a socket that every time it accepts a connection (accept()) it spawns a thread with the identifier returned by accept where the thread will write to the identifier using send(). My question is, are those identifiers returned by accept unique and
0
9591
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10225
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10053
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10001
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8880
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6676
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5312
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3573
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.