| socket.EndAccept(ar) is Exclusive....any way to change? |
|
 |
Index ‹ Visual Studio ‹ Visual Basic [VB]
|
- Previous
- 1
- Visual Basic >> Time Function ProblemI can get the Date function to work but the time Function returns the
following error at the line MyTime = Time
Run time error 450 Wrong number of arguments or invalid property assignment
Here is my code:
Private Sub cmdClickHere_Click()
Dim MyDate As Date
MyDate = Date
lblTime.Caption = MyDate
End Sub
'The above works and returns the correct value
Private Sub cmdClickHere2_Click()
Dim MyTime As Variant
MyTime = Time
lblTime2.Caption = MyTime
End Sub
'This Crashes
What am I doing wrong??
If I set the Dim MyTime as Time it still crashes with the following message:
Compile Error: Function or interface marked as restricted or the function
uses an automation type not supported in Visual Basic.
- 2
- Visual Basic >> Data repeater and Combobox?I can use the repeater fine with text boxes but can't seem to get any other controls to work.
I really want to use the dbcombo and load the listfield from a database but I guess my problem
is that I cant seem to expose the dbcombo.listfield property to work at runtime.
- 3
- Visual Basic [VB] >> image and notifyicon problemHi,
I need to change the notifyicon in a countdown. after about 3000-5000 times
there is an error.
Here is all the code. what is wrong
please help
the code needs only an notifyicon and an imagelist the timer is for changing
the icon
Jan
'start code---------------------------------
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents ImageList1 As System.Windows.Forms.ImageList
Friend WithEvents NotifyIcon1 As System.Windows.Forms.NotifyIcon
Friend WithEvents Timer1 As System.Windows.Forms.Timer
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
Me.ImageList1 = New System.Windows.Forms.ImageList(Me.components)
Me.NotifyIcon1 = New System.Windows.Forms.NotifyIcon(Me.components)
Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
'
'ImageList1
'
Me.ImageList1.ImageSize = New System.Drawing.Size(16, 16)
Me.ImageList1.TransparentColor = System.Drawing.Color.Transparent
'
'NotifyIcon1
'
Me.NotifyIcon1.Text = "NotifyIcon1"
Me.NotifyIcon1.Visible = True
'
'Timer1
'
Me.Timer1.Enabled = True
Me.Timer1.Interval = 5
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Name = "Form1"
Me.ShowInTaskbar = False
Me.Text = "Form1"
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
sBuild_100_Icons()
End Sub
Sub sBuild_100_Icons()
Dim rect As Rectangle = New Rectangle(0, 0, 32, 32)
Dim displayGraphics As Graphics = Me.CreateGraphics()
Dim img As Image = New Bitmap(rect.Width, rect.Height, displayGraphics)
Dim imageGraphics As Graphics = Graphics.FromImage(img)
Dim bcolor As Brush = New
SolidBrush(Color.FromKnownColor(KnownColor.Control))
Dim cColor As Color = Color.Red
Dim fnt As New Font(Me.Font.Name, 16, FontStyle.Bold)
For X As Byte = 0 To 99
imageGraphics.FillRectangle(bcolor, rect)
imageGraphics.DrawString(Format(X, "00"), fnt, New SolidBrush(cColor), 0, _
(rect.Height - imageGraphics.MeasureString(Format(X, "00"), fnt).Height) /
2)
Dim mybitmap As Bitmap = img
Dim hIcon As IntPtr = mybitmap.GetHicon
ImageList1.Images.Add(Icon.FromHandle(hIcon))
Next
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
Static Teller As Int64
Try
Teller += 1
Catch ex As Exception
Teller = 0
End Try
Dim mybitmap As Bitmap = ImageList1.Images(Teller Mod 100) 'I have tryed
many mod values
'te next line gives an error by the 3000-5000° times
Dim hIcon As IntPtr = mybitmap.GetHicon
NotifyIcon1.Icon = Icon.FromHandle(hIcon)
Dim sw As New System.IO.StreamWriter("teller.txt", True)
sw.WriteLine(Teller)
sw.Close()
End Sub
End Class
- 4
- VB Scripts >> Need to be able to add print option or save as option to the outpout of this script....Sorry guys, I am new to scripting and need help. The script below does
generate the info I need into an html file but the only option I can
use is to print and I need to do multiple groups and save the output
somewhere.....Anybody have a good idea I can steal????
Thanks!!!!!!
Jason Shaw
------------------------------------------------------------
Option Explicit
Dim objGroup, objUser, objExplorer, fileOutput, objMember, count
Dim strUserName, strScriptPath, strScriptName, strUserID, strScrPath
Dim strGrpName, strDirectory
count = 0
strDirectory = inputbox ("Domain/AD", "Enter the Domain or AD to
search.","Your Domain/AD Here")
strGrpName = inputbox ("Group Name", "Enter Group name to list
members.","Your Group Here")
strScriptPath = Wscript.ScriptFullName
strScriptName = Wscript.ScriptName
strScrPath = Left(strScriptPath, Len(strScriptPath) -
Len(strScriptName))
Set objGroup = Getobject("WinNT://" & strDirectory & "/" & strGrpName &
",group")
Set objExplorer = WScript.CreateObject("InternetExplorer.Application",
"IE_")
With objExplorer
.Navigate "about:Blank"
.Toolbar = 0
.StatusBar = 0
.Width = 800
.Height = 600
.Left = 75
.Top = 0
.Visible = 1
End With
Set fileOutput = objExplorer.Document
fileOutput.Open
fileOutput.WriteLn "<html>"
fileOutput.WriteLn " <head>"
fileOutput.WriteLn " <title>Current Members In '" & strGrpName &
"' Group</title>"
fileOutput.WriteLn " <style type='text/css'>"
fileOutput.WriteLn " <!--"
fileOutput.WriteLn " .head {font-family: Verdana, Arial,
Helvetica, sans-serif; font-size: 10px; font-weight: bold;
color:'#ffffff' }"
fileOutput.WriteLn " .category {font-family: Verdana, Arial,
Helvetica, sans-serif; font-size: 9px; font-weight: bold; color:
#666699 }"
fileOutput.WriteLn " .result {font-family: Verdana, Arial,
Helvetica, sans-serif; font-size: 9px; color: #000000 }"
fileOutput.WriteLn " .TableHeading {font-family: Tahoma;
font-size: 0.8em; color: black; text-align: center }"
fileOutput.WriteLn " .TableSubHeading {font-family: Tahoma;
font-size: 0.7em; color: black; text-align: center }"
fileOutput.WriteLn " .PageHeading {font-family: Tahoma;
font-size: 1.2em; color: Blue }"
fileOutput.WriteLn " .TableDetails {font-family: Tahoma;
font-size: 0.7em; font-weight: normal; text-align : left; color : white
}"
fileOutput.WriteLn " .header {font-family: Verdana; font-size:
1.2em; color: #666699; font-weight: normal; text-align : left }"
fileOutput.WriteLn " .link {cursor: hand; }"
fileOutput.WriteLn " .Copyright {font-family: Times New Roman;
font-zize: 6pt; color: #6487DC; font-size:8pt}"
fileOutput.WriteLn " a {color: '#000066'; text-decoration:none
}"
fileOutput.WriteLn " a:hover {color: '#ff0000';
text-decoration:none }"
fileOutput.WriteLn " div.page { page-break-before: always }"
fileOutput.WriteLn " .errortext {color:red}"
fileOutput.WriteLn " .hightext {color:blue}"
fileOutput.WriteLn " .warntext {color:#FFFF00}"
fileOutput.WriteLn " -->"
fileOutput.WriteLn " </style>"
fileOutput.WriteLn " </head>"
fileOutput.WriteLn " <body bgcolor='#FFFFFF' text='#000000'
link='#0000FF' vlink='000099' alink='#00FF00'>"
fileOutput.WriteLn " <table border='0' cellpadding='0'
cellspacing='0' align='center' style='border-collapse: collapse'
bordercolor='#111111' width='100%' id='TDocumentation'>"
fileOutput.WriteLn " <tr>"
fileOutput.WriteLn " <td width='15' background='"&
strScrPath & "images/coinsupg.gif' height='15'><img height='15'
alt=none src='"& strScrPath & "images/space15_15.gif' width='15'></td>"
fileOutput.WriteLn " <td colspan='3' background='"&
strScrPath & "images/sup.gif' height=15><img height='15' alt=none
src='"& strScrPath & "images/space15_15.gif' width='15'></td>"
fileOutput.WriteLn " <td width='15' background='"&
strScrPath & "images/coinsupd.gif' height='15'><img height='15'
alt=none src='"& strScrPath & "images/space15_15.gif' width='15'></td>"
fileOutput.WriteLn " </tr>"
fileOutput.WriteLn " <tr>"
fileOutput.WriteLn " <td width='15' background='"&
strScrPath & "images/g.gif'><img height='15' alt=none src='"&
strScrPath & "images/space15_15.gif' width='15'></td>"
fileOutput.WriteLn " <td colspan='3' align=center
width='100%' background='"& strScrPath & "images/fond.gif'><b> Current
Members In '" & strGrpName & "' Group </b></td>"
fileOutput.WriteLn " <td width='15' background='"&
strScrPath & "images/d.gif'><img height='15' alt=none src='"&
strScrPath & "images/space15_15.gif' width='15'></td>"
fileOutput.WriteLn " </tr>"
fileOutput.WriteLn " <tr>"
fileOutput.WriteLn " <td width='15' background='"&
strScrPath & "images/g.gif'><img height='15' alt=none src='"&
strScrPath & "images/space15_15.gif' width='15'></td>"
fileOutput.WriteLn " <td colspan='3' width='100%'
background='"& strScrPath & "images/fond.gif'
bgcolor='#b6b6b6'><hr></td>"
fileOutput.WriteLn " <td width='15' background='"&
strScrPath & "images/d.gif'><img height='15' alt=none src='"&
strScrPath & "images/space15_15.gif' width='15'></td>"
fileOutput.WriteLn " </tr>"
For Each objMember in objGroup.Members
strUserID = objMember.name
Set objUser = GetObject("WinNT://" & strDirectory & "/" &
strUserID)
strUserName = objUser.FullName
fileOutput.WriteLn " <tr>"
fileOutput.WriteLn " <td width='15' background='"&
strScrPath & "images/g.gif'><img height='15' alt=none src='"&
strScrPath & "images/space15_15.gif' width='15'></td>"
fileOutput.WriteLn " <td align='right' width='49%'
background='"& strScrPath & "images/fond.gif' bgcolor='#b6b6b6'>" &
strUserID & "</td>"
fileOutput.WriteLn " <td align='center' width='2%'
background='"& strScrPath & "images/fond.gif' bgcolor='#b6b6b6'> :
</td>"
fileOutput.WriteLn " <td align='left' width='49%'
background='"& strScrPath & "images/fond.gif' bgcolor='#b6b6b6'>" &
strUserName & "</td>"
fileOutput.WriteLn " <td width='15' background='"&
strScrPath & "images/d.gif'><img height='15' alt=none src='"&
strScrPath & "images/space15_15.gif' width='15'></td>"
fileOutput.WriteLn " </tr>"
count = count + 1
Next
fileOutput.WriteLn " <tr>"
fileOutput.WriteLn " <td width='15' background='"&
strScrPath & "images/g.gif'><img height='15' alt=none src='"&
strScrPath & "images/space15_15.gif' width='15'></td>"
fileOutput.WriteLn " <td colspan='3' align=center
width='100%' background='"& strScrPath & "images/fond.gif'
bgcolor='#b6b6b6'><hr></td>"
fileOutput.WriteLn " <td width='15' background='"&
strScrPath & "images/d.gif'><img height='15' alt=none src='"&
strScrPath & "images/space15_15.gif' width='15'></td>"
fileOutput.WriteLn " </tr>"
fileOutput.WriteLn " <tr>"
fileOutput.WriteLn " <td width='15' background='"&
strScrPath & "images/g.gif'><img height='15' alt=none src='"&
strScrPath & "images/space15_15.gif' width='15'></td>"
fileOutput.WriteLn " <td colspan='3' align=center
width='100%' background='"& strScrPath & "images/fond.gif'
bgcolor='#b6b6b6'><b>There are <i>" & count & "</i> group
members.</b></td>"
fileOutput.WriteLn " <td width='15' background='"&
strScrPath & "images/d.gif'><img height='15' alt=none src='"&
strScrPath & "images/space15_15.gif' width='15'></td>"
fileOutput.WriteLn " </tr>"
fileOutput.WriteLn " <tr>"
fileOutput.WriteLn " <td width='15' background='"&
strScrPath & "images/coininfg.gif' height='15'><img height='15'
alt=none src='"& strScrPath & "images/space15_15.gif' width='15'></td>"
fileOutput.WriteLn " <td colspan='3' background='"&
strScrPath & "images/inf.gif' height='15'><img height='15' alt=none
src='"& strScrPath & "images/space15_15.gif' width='15'></td>"
fileOutput.WriteLn " <td width='15' background='"&
strScrPath & "images/coininfd.gif' height='15'><img height='15'
alt=none src='"& strScrPath & "images/space15_15.gif' width='15'></td>"
fileOutput.WriteLn " </tr>"
fileOutput.WriteLn " </table>"
fileOutput.WriteLn " </body>"
fileOutput.WriteLn "<html>"
fileOutput.close
WScript.Quit
- 5
- Visual Basic >> Finding the mail serverI am trying to figure out how to programatically determine the
available or default mail server of a machine. I'm writing a small
app that sends emails through the system at various prompts, but I
will be installing it at locations with differing mail servers.
TIA
- 6
- Visual Basic >> Cartier Pasha Seatimer Steel Mens Watch W31080M7 ReplicaCartier Pasha Seatimer Steel Mens Watch W31080M7 Replica, Fake, Cheap,
AAA Replica watch
Cartier Pasha Seatimer Steel Mens Watch W31080M7 Link :
http://www.aaa-replica-watch.com/cartier_w31080m7.html
Buy the cheapest Cartier Pasha Seatimer Steel Mens Watch W31080M7 in
toppest Replica . www.aaa-replica-watch.com helps you to save money!
cartier-w31080m7 , Cartier Pasha Seatimer Steel Mens Watch W31080M7 ,
Replia , Cheap , Fake , imitation , Cartier Watches
Cartier Pasha Seatimer Steel Mens Watch W31080M7 Information :
Brand : Cartier Watches (http://www.aaa-replica-watch.com/
Replica_Cartier.html )
Gender : Mens
Model : cartier-w31080m7
Case Material : Stainless Steel
Case Diameter : W31080M7, Cartier-W31080M7
Dial Color : Silver
Bezel : Fixed
Movement : Automatic
Clasp : Stainless Steel
Water Resistant : 100m/330ft
Crystal : Scratch Resistant Sapphire
Our Price : $ 225.00
Silver dial. Self Winding Automatic Calibre 49 Movement. Luminescent
Diamond Shaped Steel Hands. Steel Screw Down Crown Cover. 7"
Adjustable Bracelet. Stainless Steel case. 40.5mm (1.5") dial.
Deployment Buckle clasp. 100 Meters / 330 Feet Water Resistant.
Scratch Resistant Sapphire Crystal.
Cartier Pasha Seatimer Steel Mens Watch W31080M7 Replica, With the mix
of finest craftsmanship and contemporary styling, not only does it
reflect the time but also care you put into looking good. choose one
to promote your quality and make yourself impressive among people
Thank you for choosing www.aaa-replica-watch.com as your reliable
dealer of quality waches including Cartier Pasha Seatimer Steel Mens
Watch W31080M7 . we guarantee every watch you receive will be exact
watch you ordered. Each watch sold enjoy one year Warranty for free
repair. Every order from aaa-replica-watches is shipped via EMS, the
customer is responsible for the shipping fee on the first order, but
since the second watch you buy from our site, the shipping cost is
free. Please note that If the total amount of payment is over
$600(USD), the customer is required to contact our customer service
before sending the money in case failed payment. If you have any other
questions please check our other pages or feel free to email us by
service@aaa-replica-watch.com.
The Same Cartier Watches Series :
Cartier 21 Chronoscaph Unisex Watch W10198U2 :
http://www.aaa-replica.com/Cartier_21_Unisex_Watch_W10198U2.html
Cartier 21 Chronoscaph Unisex Watch W10197U2 :
http://www.aaa-replica.com/Cartier_21_Unisex_Watch_W10197U2.html
Cartier Must 21 Two-Tone Steel Ladies Watch W10073R6 :
http://www.aaa-replica.com/Cartier_W10073R6.html
Cartier Must 21 Steel Ladies Watch W10109T2 :
http://www.aaa-replica.com/Cartier_W10109T2.html
Cartier Must 21 Chronoscaph Unisex Watch W10184U2 :
http://www.aaa-replica.com/Cartier_W10184U2.html
Cartier Must 21 Chronoscaph Mens Watch W10125U2 :
http://www.aaa-replica.com/Cartier_W10125U2.html
Cartier Must 21 Chronoscaph Mens Watch W10172T2 :
http://www.aaa-replica.com/Cartier_W10172T2.html
Cartier Must 21 Steel Mens Watch W10110T2 :
http://www.aaa-replica.com/Cartier_W10110T2.html
Cartier Must 21 Two-Tone Steel Mens Watch W10072R6 :
http://www.aaa-replica.com/Cartier_W10072R6.html
Cartier Tank Solo Steel Orange Alligator Ladies Watch W1019455 :
http://www.aaa-replica.com/Cartier_W1019455.html
Cartier Tank Solo Steel White Alligator Ladies Watch W1019555 :
http://www.aaa-replica.com/Cartier_W1019555.html
Cartier Tank Solo 18kt Yellow Gold Mens Watch W1018855 :
http://www.aaa-replica.com/Cartier_W1018855.html
- 7
- Visual Basic >> VB trusted or not trusted with Outlook2003Hi
This is probably not a VB issue, but this is by far the best place to ask
questions.
My Customer has upgraded some of it's clients to Outlook2003 and since then
each client gets some extra warnings when running my application.
The warning starts like: "A program is trying to access e-mail addresses
you have stored in Outlook" and then there are some options to let it pass or
not.
(since these users have VERY limited rights they have to respond to this
warning every time the app needs to interact with Outlook)
I found some articles on MSDN regarding this but I cannot fully understand
exactly how to resolve it; apparantly someone must make my application a
trustee with Outlook2003 !!!!
Anyway: My questions are these;
Is it on my side or on my customers side this "trustee" configuration must
take place?
Which part of my application is it that must be a trustee ??
(In the articles it's refered to some COM's, I'm not sure what this means)
Rgds
Kjell
- 8
- Visual Basic >> Automatically Insert Line Labels for ErlDoes anyone know of any freeware or shareware code for inserting line
numbers in code?
I love using the Erl function (Feature, statement, whatever the thing is
called. It's not documented anymore) but I hate inserting the line numbers
"by hand".
TIA
- 9
- MFC >> How to create CDialog from different DLL?Hello,
Iâ??m trying to create a CDialog object, which is defined in one DLL from a
class in another DLL.
The dialog appears to be successfully created but its handle is invalid,
when Iâ??m trying to use "this" the application crashes with a debug assertion
at wincore.cpp "LookupPermanent".
Do you have any suggestion how to solve this problem?
Thanks,
Limor
- 10
- Visual Basic [VB] >> Newbie Keypress QuestionDoes anyone know how to remove keypress events at form level before
they are passed onto individual controls?
For example I have a text box in my form. I set keypreview to true.
In VB 6 when I received the form_Keypress I would set the keyascii =
0. This way the text box didn't get the keypress. Is there a way to
do the same thing in vbDotNet?
TIA
Terry
- 11
- Visual Basic >> HtmlHelp reload same fileHello to all, I have the following problem:
I call for the first time:
Call HtmlHelp(hWnd, "helpITA.chm", HH_HELP_CONTEXT, dwData)
and it appears a window with the Italian Help
then, I call for the second time
Call HtmlHelp(hWnd, "helpENG.chm", HH_HELP_CONTEXT, dwData)
and it appears a window with the same italian help and not english
help.
HtmlHelp seems to not load another file.
Can anyone help me?
thank you
Luca
- 12
- 13
- MFC >> Indexing serviceHi,
Using Indexing service, I am trying to get the properties of file(s),
based on the search criteria.
Can anyone help me to do this using the API, in vc++ 6.0.
thank u.
- 14
- Visual Studio C++ >> exception won't catchI have an MFC application that runs off a network drive. It uses an
Oracle database, and the server is also on the network. The problem I'm
having is that if a workstation loses connection to the network during a
work session, the application will crash when trying to save data back
to the database. "Crash" being that the app simply terminates and goes
back to Windows desktop.
The data save code is wrapped within try / catch blocks. If I run the
application locally from my C drive, the exception is caught and handled
gracefully. But when running from the network, the catch block isn't
being called. I know this because there is a MessageBox that should
notify the user of a problem, and it doesn't come up.
So my question is, why does this happen? And what's the most elegant way
to get around it? If I can't get the catch to execute on failure, then
I'll need another method of knowing that the LAN is present before
trying to save.
Thanks for any ideas.
- 15
- MFC >> fprintfMy application runs fine on a laptop with Windows 2000,
SP2, but when I run it on my PC with Windows 2000, SP3, I
get an fprintf error message that terminates the
application. The exact error is:
File: fprintf.c
Line: 56
Expression: str != NULL
Any suggestions??
|
| Author |
Message |
Athrivarada

|
Posted: Tue Jan 02 01:52:57 CST 2007 |
Top |
Visual Basic [VB] >> socket.EndAccept(ar) is Exclusive....any way to change?
Hi, im making an AIM like server using TCP sockets, however i found a big
issue. when a socket is connected to (socket.EndAccept(ar)), its already
bound to a Port. since its bound, i cannot change its access to non
exclusive, but i need this port to still be open because i may need another
socket to connect on this port as well. how can i achieve this?
--
-iwdu15
Visual Studio264
|
| |
|
| |
 |
Tom

|
Posted: Tue Jan 02 01:52:57 CST 2007 |
Top |
Visual Basic [VB] >> socket.EndAccept(ar) is Exclusive....any way to change?
On 2007-01-02, iwdu15 <jmmgoalsteratyahoodotcom> wrote:
> Hi, im making an AIM like server using TCP sockets, however i found a big
> issue. when a socket is connected to (socket.EndAccept(ar)), its already
> bound to a Port. since its bound, i cannot change its access to non
> exclusive, but i need this port to still be open because i may need another
> socket to connect on this port as well. how can i achieve this?
You may need to explain this situation a little more clearly (maybe some short
code samples would be helpfull).
--
Tom Shelton
|
| |
|
| |
 |
Martin

|
Posted: Tue Jan 02 02:50:51 CST 2007 |
Top |
Visual Basic [VB] >> socket.EndAccept(ar) is Exclusive....any way to change?
From what I remember of doing something similar a few years ago; You have a
'listening' socket and every time that socket detects an incoming connection
you open a new socket on a different port and make the connection on that
port. That way you can continue to listen on the original socket.
I don't have code samples to hand anymore i'm afraid.
HTH
"iwdu15" <jmmgoalsteratyahoodotcom> wrote in message
news:EMail@HideDomain.com...
> Hi, im making an AIM like server using TCP sockets, however i found a big
> issue. when a socket is connected to (socket.EndAccept(ar)), its already
> bound to a Port. since its bound, i cannot change its access to non
> exclusive, but i need this port to still be open because i may need
> another
> socket to connect on this port as well. how can i achieve this?
> --
> -iwdu15
|
| |
|
| |
 |
Tom

|
Posted: Tue Jan 02 03:06:33 CST 2007 |
Top |
Visual Basic [VB] >> socket.EndAccept(ar) is Exclusive....any way to change?
On 2007-01-02, Martin <EMail@HideDomain.com> wrote:
> From what I remember of doing something similar a few years ago; You have a
> 'listening' socket and every time that socket detects an incoming connection
> you open a new socket on a different port and make the connection on that
> port. That way you can continue to listen on the original socket.
You are correct, that is how it is supposed to work - except, you don't open a
new socket. A new socket is returned to you via the accept method. I think
the op is confused about this - and is actually trying to communicate with the
client using the server socket. But, I'm not quite sure - hence the request
for clarification and code demonstrating the issue.
Some people fine the TcpListener/TcpClient classes useful - but to be honest,
I prefer to use the Socket class directly. That's a personal preference,
probably developed out of problems/bugs I experienced during the early beta's
:)
--
Tom Shelton
|
| |
|
| |
 |
jmmgoalsteratyahoodotcom>

|
Posted: Tue Jan 02 18:28:01 CST 2007 |
Top |
Visual Basic [VB] >> socket.EndAccept(ar) is Exclusive....any way to change?
right, thats my problem. a Socket is given to me by the function
EndAccept(..), this socket is already bound to a port, so i cannot change it
to non-exclusive. is there any way to change that?
--
-iwdu15
|
| |
|
| |
 |
Chris

|
Posted: Wed Jan 03 11:55:39 CST 2007 |
Top |
Visual Basic [VB] >> socket.EndAccept(ar) is Exclusive....any way to change?
"iwdu15" <jmmgoalsteratyahoodotcom> wrote
> Hi, im making an AIM like server using TCP sockets, however i found a big
> issue. when a socket is connected to (socket.EndAccept(ar)), its already
> bound to a Port. since its bound, i cannot change its access to non
> exclusive, but i need this port to still be open because i may need
> another
> socket to connect on this port as well. how can i achieve this?
Let's say you have a socket listening, on (for example) port 5222. You put
the socket into BeginAccept mode, and then out of the blue you get a
callback. In your callback method you call EndAccept, and get a reference to
a new socket (this is KEY!).
In the NEW socket, you call BeginReceive to start the whole receive process.
You now have a connected client.
On the original socket you call "BeginAccept()" again - this allows
additional users to connect. This algorithm is then repeated forever, and
you have a server that scales very well.
--
Chris Mullins, MCSD.NET, MCPD:Enterprise, MVP C#
http://www.coversant.net/blogs/cmullins
|
| |
|
| |
 |
jmmgoalsteratyahoodotcom>

|
Posted: Wed Jan 03 17:33:00 CST 2007 |
Top |
Visual Basic [VB] >> socket.EndAccept(ar) is Exclusive....any way to change?
yea, i realize this much. however, what i was confused about was wouldnt the
server throw an error the next time a connection attempt was made? like if
you try to bind more than one socket to a port without saying it does not
have exclusive access, an error is thrown. so when you receive a connection
attempt, the socket handed to you by EndReceive(...) is automatically
non-exclusive?
--
-iwdu15
|
| |
|
| |
 |
Tom

|
Posted: Wed Jan 03 23:48:31 CST 2007 |
Top |
Visual Basic [VB] >> socket.EndAccept(ar) is Exclusive....any way to change?
On 2007-01-03, iwdu15 <jmmgoalsteratyahoodotcom> wrote:
> yea, i realize this much. however, what i was confused about was wouldnt the
> server throw an error the next time a connection attempt was made? like if
> you try to bind more than one socket to a port without saying it does not
> have exclusive access, an error is thrown. so when you receive a connection
> attempt, the socket handed to you by EndReceive(...) is automatically
> non-exclusive?
The socket handed to you by the EndReceive is a completly new and different
socket then the one that accepted the request. It is on a completly different
port, so you can have many client connect to the server sockets known port. The
conversation between the server and the client happens on the port allocated
to the new socket....
--
Tom Shelton
|
| |
|
| |
 |
Bart

|
Posted: Thu Jan 04 06:26:12 CST 2007 |
Top |
Visual Basic [VB] >> socket.EndAccept(ar) is Exclusive....any way to change?
Hi,
"Tom Shelton" <EMail@HideDomain.com> wrote in message
news:EMail@HideDomain.com...
> On 2007-01-03, iwdu15 <jmmgoalsteratyahoodotcom> wrote:
>> yea, i realize this much. however, what i was confused about was wouldnt
>> the
>> server throw an error the next time a connection attempt was made? like
>> if
>> you try to bind more than one socket to a port without saying it does not
>> have exclusive access, an error is thrown. so when you receive a
>> connection
>> attempt, the socket handed to you by EndReceive(...) is automatically
>> non-exclusive?
>
> The socket handed to you by the EndReceive is a completly new and
> different
> socket then the one that accepted the request.
That's right.
>It is on a completly different
> port, so you can have many client connect to the server sockets known
> port. The
> conversation between the server and the client happens on the port
> allocated
> to the new socket....
That's wrong. The new socket uses the same server port. A TCP server can
have many clients connected to the same port. When (connected) clients sent
packets to the server, the TCP stack can distinguish the received packets
based on the source IP and source port which is part of the IP/TCP header
that is sent along.
HTH,
Greetings
>
> --
> Tom Shelton
|
| |
|
| |
 |
Tom

|
Posted: Thu Jan 04 15:22:12 CST 2007 |
Top |
Visual Basic [VB] >> socket.EndAccept(ar) is Exclusive....any way to change?
Bart Mermuys wrote:
> Hi,
>
> "Tom Shelton" <EMail@HideDomain.com> wrote in message
> news:EMail@HideDomain.com...
> > On 2007-01-03, iwdu15 <jmmgoalsteratyahoodotcom> wrote:
> >> yea, i realize this much. however, what i was confused about was wouldnt
> >> the
> >> server throw an error the next time a connection attempt was made? like
> >> if
> >> you try to bind more than one socket to a port without saying it does not
> >> have exclusive access, an error is thrown. so when you receive a
> >> connection
> >> attempt, the socket handed to you by EndReceive(...) is automatically
> >> non-exclusive?
> >
> > The socket handed to you by the EndReceive is a completly new and
> > different
> > socket then the one that accepted the request.
>
> That's right.
>
> >It is on a completly different
> > port, so you can have many client connect to the server sockets known
> > port. The
> > conversation between the server and the client happens on the port
> > allocated
> > to the new socket....
>
> That's wrong. The new socket uses the same server port. A TCP server can
> have many clients connected to the same port. When (connected) clients sent
> packets to the server, the TCP stack can distinguish the received packets
> based on the source IP and source port which is part of the IP/TCP header
> that is sent along.
Your are correct of course. My bad. It was too late at night for me
to be thinking clearly. The local end point of the new socket is the
same as the servers, it is differentiated by the remote endpoint - the
ip:port from which the connection originated.
--
Tom Shelton
|
| |
|
| |
 |
| |
 |
Index ‹ Visual Studio ‹ Visual Basic [VB] |
- Next
- 1
- 2
- Visual Basic [VB] >> Using VB 6.0 Interface in vb.net causes a problemHi,
I have an interface in vb 6.0. It has a property set member, which takes a
parameter by reference. When I try to implement this interface in my vb.net
project it gives me an error saying that "cannot implement property set
because there is no matching property on interface". I think .NET does not
allow parameter to be passed ByRef in property statements.
here is my property set statement in vb 6.0 interface called IName
Property Set Name(ByRef objName as object)
End Property
VB.NET code looks like this
Public WriteOnly Property Name() as System.IntPtr implements IName.Name
Set (ByVal value as System.IntPtr)
end set
End Property
There is an underline below IName.Name. When I put my mouse over it then it
says "Cannot implement IName.Name because there is no matching property on
Interface IName". I tried changing the System.IntPtr to System.Object but it
gives the same result. I cannot change vb 6.0 interface to accept parameter
ByVal instead of ByRef because then, I have to change all other existing
components that already are implementing this interface.
Your help is appreciated.
Thanks
- 3
- MFC >> Tooltip causes an ASSERT() in a child dialog boxHello experts,
I already posted about my problem a couple of days ago, but it's not
solved yet and I have some more details about it.
Using MS VC 6.0 and Vista.
I create a CTabCtrl control in a dialog box. For each tab, a child
dialog box contains a bunch of controls (CEdit, CComboBox...). I can
display tooltips for each control, no problem.
The problem is that when the cursor (I mean the mouse) leaves a
control, if it enters the tooltip area, I get an ASSERT() warning:
In WinCore.cpp
void CWnd::AssertValid() const
{
...
// should be a normal window
ASSERT(::IsWindow(m_hWnd));
...
}
This occurs only when the dialog boxes displayed in the tabs are CHILD
dialog boxes. If I choose "Overlapped" or "Popup", it works (but I
need a child dialog box).
What should I do to avoid this problem?
TXS
Phil
- 4
- Visual Basic [VB] >> Class controling form settingsI am wondering if it is possible to make something like the following work:
Public Class myTestSettings
Public Property onTop() As Boolean
Get
Return Form1.CheckBox1.Checked
End Get
Set(ByVal Value As Boolean)
Form1.CheckBox1.Checked = Value
End Set
End Property
End Class
Second question: if it is possible, is it advisable?
I am wanting to serialize this information to an XML file. I'm exploring
this as a possibly better way to accomplish this.
Thanks in advance,
Matthew
- 5
- Visual Basic [VB] >> enable tabcontrolon my form I have a checkbox and a tab control when the checkbox is true I
wish to enable the controls on a single page of the tab control, is this
possible or do I need to enable each control on the tab control page.
if you could supply and example of code it would be much appreciated
thanks phil
- 6
- VB Scripts >> Variables from one script to anotherHi...
I posted this before, but probably didn't explain my self well...
I need to have a script that declares and sets a value for some vb
variables, and want to have the value in these variables available in other
script...
Here is what I do :
I have a master script that calls other scripts...
1st script called from master script, it declares and sets values for some
variables ...
ex : Public appver1
appver1 = "V9_4_2"
2nd script called from master script would use the variables set in 1st
script to do execute actions with it...
ex : WshEnv("Var1") = appver1
How can this be done ...
The value is "appver1" is not necessary outside of the vb environment...
Reason is that 1st script will be modified by a lot of people, but don't
want them to modify other script...
Thanks very much !!!
--
--
Houman Yahyaei ( CCNA, MCSE Win 2000/NT 4.0, MCT )
IT Training and Consulting
www.formationhy.com
Houman@formationhy.com
- 7
- VB Scripts >> How do I output the Text between 2 strings to a text file?HELP!I am trying to output the text between two strings , i giot to wite a
routine somthing as shown,but the output text file is BLANK!What am I
doing wron?I am new to VB script...Please Help!
Ajay
startstring = "ASSOCIATION TOTALS BY ACCOUNT TYPE"
endstring = "TOTAL""
sData = ReadFile("C:\Documents and Settings\Owner.AJAYGARG\My_
Documents\ASSOCIATION TOTALS BY ACCOUNT TYPE.doc")
startposition = InStr(sData, startstring)
sData = Left(sData, startposition)
endposition = InStr(sData, endstring) + Len(endstring) - 1
sData = Left(sData, endposition)
WScript.echo sData
Function ReadFile(FilePath)
'Given the path to a file, will return entire contents
' works with either ANSI or Unicode
Dim FSO, CurrentFile
Const ForReading = 1, TristateUseDefault = -2, _
DoNotCreateFile = False
Set FSO = createobject("Scripting.FileSystemObject")
If FSO.FileExists(FilePath) Then
If FSO.GetFile(FilePath).Size>0 Then
Set CurrentFile = FSO.OpenTextFile(FilePath, ForReading, _
False, TristateUseDefault)
If CurrentFile.AtEndOfStream <> True Then
ReadFile = CurrentFile.ReadAll
WriteFile "C:\Documents and Settings\Owner.AJAYGARG\My
Documents\ASSOCIATION TOTALS BY ACCOUNT TYPEf.doc", outData
: CurrentFile.Close
End If
End If
End If
End Function
Sub WriteFile(FILEPATH, sData)
'writes sData to FilePath
With CreateObject("Scripting.FileSystemObject")._
OpenTextFile(FilePath, 2, True)
.Write sData: .Close
End With
End Sub
- 8
- 9
- Visual Basic [VB] >> Mismatch between sample code and wizard skeleton/starting point ?I have a question regarding code examples in the msdn cd.
For example I will refer to the help page titled
"Using TCP Services"
As we can see, the code below is supposed to be for
a console application. My question is this: if I create
a console application with the wizard, I get a Main
sub which is inside Module1, whereas here, in the
sample, main is in a class called TcpTimeClient.
I.e. there is some implicit understanding here that one
would know how to insert this sample into the basic
template that the Console Application wizard gives
us. Is this mentioned anywhere ?
[Visual Basic]
Imports System
Imports System.Net.Sockets
Imports System.Text
Public Class TcpTimeClient
Private const portNum As Integer = 13
Private const hostName As String = "host.contoso.com"
' Entry point that delegates to C-style main Private Function.
Public Overloads Shared Sub Main()
System.Environment.ExitCode = _
Main(System.Environment.GetCommandLineArgs())
End Sub
Overloads Public Shared Function Main(args() As [String]) As Integer
Try
Dim client As New TcpClient(hostName, portNum)
Dim ns As NetworkStream = client.GetStream()
Dim bytes(1024) As Byte
Dim bytesRead As Integer = ns.Read(bytes, 0, bytes.Length)
Console.WriteLine(Encoding.ASCII.GetString(bytes, 0, bytesRead))
Catch e As Exception
Console.WriteLine(e.ToString())
End Try
client.Close()
Return 0
End Function 'Main
End Class 'TcpTimeClient
- 10
- Visual Basic [VB] >> Unable to access c# code from VB.NET in the same solutionThis is a little puzzling,
I have a solution (SolutionA)
and have about 14 Projects in it that are VB.NET
I have to use some code which is C# and thought I could just add a reference
and use that to call the methods in the file. Seeems not to be the case, I
have added the reference but the project's classes or project reference does
not show up on the autolist that imports gives.
essentially the solution doesn't see the csharp class.
any ideas?
- 11
- Visual Studio C++ >> Seeking opinions of best practice on splitter windowsHello
When having a splitter window, i.e. a window that is about 5 pixels wide and
goes between the left-hand treeview and the right hand control, be it mdi
client window or listview or whatever, is it generally preferred practice to
have the left and right windows resize as the user is dragging the splitter
window, or to wait until the splitter window is dropped.
I notice that most Microsoft applications (e.g. Windows Explorer, Outlook
Express) go for the former, however it seems Visual Studio .NET adopts the
latter strategy.
I've coded my application so that it works like Visual Studio .NET. However
I can't make the splitter window adopt that transparent-gray crosshatch
pattern when it is being dragged, anybody know off-hand what the background
needs setting to to make it like that?
And also, which is the 'best-practice' method, or doesn't it generally
matter either way?
- 12
- VB Scripts >> Accessing a c#.net created COM object in vbscript...Hey guys.
How do I access a COM object in vbscript?
I created the object using c#, but am unsure :
- which guid to use
- which object id
- whether i should use the <OBJECT> tag at all
- how to handle create object...
my structure for the COM object is as follows ( created following the
tutorial found at http://www.csharphelp.com/archives/archive281.html )
//----------------------------------------- start c# code
namespace BIF_COM_API
{
//
// Interface Declaration
//
[Guid("49B9D855-182A-4064-A362-95D7D10C4E15")]
public interface BIF_Interface
{
//
// DispId declarations
//
}
//
// Events Interface
//
[Guid("09603A1F-E672-4460-9F66-D012CE9F9842"),
InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface BIF_Events
{
}
//
// COM object instantiation
//
[Guid("1995FED2-2C21-4659-A5E4-B832C0BD4434"),
ClassInterface(ClassInterfaceType.None),
ComSourceInterfaces(typeof( BIF_Events ))]
public class BIF_Instantiation : BIF_Interface
{
//
// class implementation
//
}
}
//----------------------------------------- end code
and my current vbscript code is
//----------------------------------------- vbscript code
<!-- header stuff -->
<SCRIPT LANGUAGE="VBScript">
<!--
option explicit
sub VB_Click
Dim bifapi
bifapi = CreateObject ( "BIF_Instantiation" )
' error here, can't create
object
bifapi.SetDestinationQueueName "Local_In"
bifapi.Send
end sub
-->
</SCRIPT>
</HEAD>
<OBJECT
classid="clsid:49B9D855-182A-4064-A362-95D7D10C4E15"
id=BIF_COM_API.BIF_Interface
VIEWASTEXT>
</OBJECT>
<BODY>
<!-- body stuff.... -->
//----------------------------------------- end code
thanks for your help in anticipation.
Daniel.
- 13
- Visual Basic >> PDW Msg "...already been added..."When packaging my project, I am asked to "choose the folder where your
package will be assembled." I click the "New Folder" icon and make a folder
and select next. There is a processing delay (only 550MHz machine) and the
drive rattles, then I am prompted with "Afile with this name has already
been added to the list of files." You only have the choice to click OK.
Does anyone know what causes this message?
Regards,
Jim
- 14
- MFC >> Message which is called everytime a CFormView is createdHallo,
I have a program with a CSplitterWnd which divides 2 CFormViews.
See link: http://wwwstud.fh-zwickau.de/~pafe/geb/1.jpg
When I start the program the ListBox (CListView) on the right side
gets filled in the method OnInitialUpdate().
When I navigate through the tree then the views on the right side are
replaced.
When I come back to the element, that displays the form with the
List-Box, my ListBox is not filled with the data I provide in
OnInitialUpdate.
See link: http://wwwstud.fh-zwickau.de/~pafe/geb/2.jpg
Now my question is:
Where do I have to put the code (what message do I have to catch) to
get the ListBox filled everytime I select the corresponding
tree-element.
Thx 4 ur help
Pedde
- 15
- Visual Basic >> Print preview and print for picture controlI have a form that acts as a container for a picture control. I am
drawing pictures in the picture control, and would like to add print
preview and print functionality - but I don't know how to do this.
i would be grateful if someone could provide a code snippet that shows
how I may ;
1). print preview an image displayed in a picture control
2). print the image displayed in the picture control
|
|
|