-
Question about "disconnecing" TCP connections
This is my first post on this site, so please don't yell at me if this is in the wrong forum. So, real quick, a little about myself (If you prefer to jump straight to my question scroll down...):
I am 28 years old and have been a teacher for 5 years. I have been programing for about 2 1/2 - 3 years now, and I have taught myself everything I know (with the help of sites like this and others). It started out as just some experimental things involving editing emulator games. Then it progressed into bigger projects like writing small applications for myself to use at school. As of late, I have been working with some people over at football-freaks.com to mod Madden '08 into a Madden '09 (because EA isn't releasing one for the computer). And I am also working on an attendance program for my school (if I can learn more about actual server/client programming). This leads me to my question, actually...
QUESTION STARTS HERE! 
All of that is all fine and good, but I also have been working on a project of my own that started back 2 years ago with visual basic 6.0 and now I have completely upgraded into visual basic 9.0. The only issue is that part of the program gives me the local ip address, local port, remote ip address and remote port for everything that has that sort of connection to me at any given time (whether it be via internet, hosting a game, etc...). What I can't figure out is how to create a line(s) of code to disconnect certain connections.
For example, let's say this is all in a list. One of the things in the list has these values:
Local Address: 192.168.0.100
Local Port: 6112
Remote Address: 123.45.678.90
Remote Port: 12345
I want to "disconnect" that particular connection. Does that make sense? I figured that knowing that information should be good enough using things like sockets (maybe..) and stuff. The problem is that I have very little expertise using sockets. In visual basic 6, I just "stole" the code from some site online and it worked fine. In VB9, however, I have figured it out most of it on my own, and would like guidance for this last little part.
Any help/guidance/direction to other sites that might help is GREATLY appreciated!
JD
-
Welcome to DevX 
What is the VB6 code you are using for this? Perhaps "translating" that into VB.NET would be easier than trying to come up with something from scratch.
-
Code:
Public Sub DisconnectTCP_Click(Index As Integer)
Dim TcpTableRow As MIB_TCPROW
Dim lngRetValue As Long
TcpTableRow = TCPConnections(index).TCPRowNumber
TcpTableRow.dwState = MIB_TCP_STATE_DELETE_TCB
lngRetValue = SetTcpEntry(TcpTableRow)
End Sub
The "SetTcpEntry" functions comes from here:
Code:
Public Declare Function SetTcpEntry Lib "iphlpapi.dll" (ByRef pTcpTable As MIB_TCPROW) As Long
The TCPConnections array holds all the info from the TCPTable (remote Address, Local Address, Ports, etc...). I have already converted this over to VB9, but it does not seem to work correctly...
Thanks for taking a look.
JD
-
How are these declared:
MIB_TCPROW
MIB_TCP_STATE_DELETE_TCB
-
 Originally Posted by Hack
How are these declared:
MIB_TCPROW
MIB_TCP_STATE_DELETE_TCB
Code:
Public Class MIB_TCPROW
Public dwState As Integer
Public dwLocalAddr As Integer
Public dwLocalPort As Integer
Public dwRemoteAddr As Integer
Public dwRemotePort As Integer
End Class
Private Const MIB_TCP_STATE_CLOSED As Short = 1
Private Const MIB_TCP_STATE_LISTEN As Short = 2
Private Const MIB_TCP_STATE_SYN_SENT As Short = 3
Private Const MIB_TCP_STATE_SYN_RCVD As Short = 4
Private Const MIB_TCP_STATE_ESTAB As Short = 5
Private Const MIB_TCP_STATE_FIN_WAIT1 As Short = 6
Private Const MIB_TCP_STATE_FIN_WAIT2 As Short = 7
Private Const MIB_TCP_STATE_CLOSE_WAIT As Short = 8
Private Const MIB_TCP_STATE_CLOSING As Short = 9
Private Const MIB_TCP_STATE_LAST_ACK As Short = 10
Private Const MIB_TCP_STATE_TIME_WAIT As Short = 11
Private Const MIB_TCP_STATE_DELETE_TCB As Short = 12
Similar Threads
-
Replies: 0
Last Post: 04-18-2005, 05:25 AM
-
By ASP learner in forum ASP.NET
Replies: 5
Last Post: 10-08-2002, 07:17 PM
-
Replies: 1
Last Post: 02-03-2002, 03:23 AM
-
By Mikael Nyberg in forum Mobile
Replies: 0
Last Post: 06-26-2001, 04:30 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|