Threading And Socket Connections Approach

Jul 2, 2011

Im writing a small application that need to make up to 300 socket connections at the same time. However i'm pretty confused on how to approach this. My first theory is to have my main thread to manually fire up 300 new threads that each handle all that needs to be done. Another theory is to fire up lets say 10 threads that makes 30 async connections. My last theory is to have my mainthread work with all 300 async connections together with everything else. The question to this is what would be the most effective way to go to save resources and maintain speed.

View 1 Replies


ADVERTISEMENT

Why Does Threading Approach Not Work

Jun 16, 2010

I have a wierd problem with threading in an ASP.NET application. For some reason, when I run the code in the request thread, everything works as expected. But when I run it in a separate thread, nothing happens.This is verified by calling the below handler with the three flags "on", "off" and "larma" respectively - in the two first cases everything works, but in the latter nothing happens.[code]

View 4 Replies

Threading And Db Connections In Vb?

Feb 23, 2011

I'm trying to understand how to handle db connections in a multi-theaded windows program.It I have this simple class:

public class MyClass
private myConn as new sqlconnection
private MyThreadPool(5) as Thread

[code]....

View 10 Replies

Multiple Socket Connections?

Nov 14, 2010

OK here is some code I nicked from web and I have changed some things, it works but only accepting one client, how do I make this accept multiple clients?

[Code]...

View 2 Replies

Multiple Socket Connections Per Thread?

Sep 8, 2011

We are using VB.NET 2010. Our application receives client connection through socket, and currently each client has its own thread and socket. We would like to have multiple socket connections per thread, but we are having a problem doing it.

Below is our current program where each client has itsown tread and socket.
Public class frmMyForm:
Private Sub AcceptSocket(ByVal Sock As SocketTools.SocketWrench)
Try
Dim oSession As SessionClass
Dim oThread As Threading.Thread
[Code] .....

View 1 Replies

Multiple Socket Connections - Address Of Parameters?

Mar 2, 2012

I am writing a socket client into my application. I have multiple socket connections to make to different servers.
ClientSocket(1).BeginConnect(endpoint1, AddressOf Connected, Nothing)
ClientSocket(2).BeginConnect(endpoint2, AddressOf Connected, Nothing)
Both clients call the connected sub... how do I know which one is which?
Private Sub Connected(ByVal ar As IAsyncResult)

View 3 Replies

Instantiate Multiple Sql Connections To The Same Database Via Threading Without Getting An Error?

Apr 8, 2011

I'm running a program where I call a function which creates a database connection and then runs a stored procedure. I call this function four times from four separate threads. I get an error (Login failed for user 'sa'. The user is not associated with a trusted SQL Server connection.

Exception Source:
.Net SqlClient Data Provider)
when I use multiple threads, but if I have the threads run one after another I have no

[code].....

View 1 Replies

VS 2008 Async Socket Connections - Clear Out No Longer Useful Sockets From The Server?

Dec 18, 2009

I have been developing an async socket connection server and client program. I have been testing it, and noticed that if I connect to the server from my client and then disconnect. Upon reconnecting I am on a different port(local IP still). This is fine, however when I go to send a message, and the server trys to update all the clients, it eventually hits clients that do not exist anymore. I get the SocketException 10054, and upon connecting/disconnecting enough, it no longer works at all. My question is how do I clear out these no longer useful sockets from the server? I am doing currentsocket.Shutdown(SocketShutDown.Both); and then a currentsocket.Close(); after that. When a user disconnects.

[Code]...

View 1 Replies

Threading Windows Service TCP Socket Client?

Jan 22, 2012

I'm trying to build a multithreaded SMPP client with VS2008 and I'm getting bogged down in threading. Basically my main parent thread will interact with the windows service scheduler, get registry settings, and get a list of SMPP servers to connect to. Then it will launch a thread for each SMPP connection, which will need to keep it's TCP socket open to receive messages with, so the thread must remain running even if there aren't any events happening (no messages to receive)... but I can't seem to get it figured out.

[Code]...

The Start sub in the oChannel object does run, but once that sub is finished running the thread ends. In the Start sub, it calls other code that initiates a connection to the remote SMPP server, but that code asynchronously waits for an event to be raised regarding the connection status. Once the sub finishes, the async connection being attempted doesn't seem to be able to pin the thread down.

View 3 Replies

.Net SQLClient Connections And SQL Server - Active Connections Reflect Even Though All Closed?

Jul 19, 2011

Using VB.Net and SQL Server 2008 R2: I have recently had a database that using sp_who2 reflects a connection ".Net SqlClient Data Provider" is still active even though the .Net application has closed and disposed of all connections.

[Code]...

View 1 Replies

Identify Connection Lost Between Socket Server And Socket Client?

May 21, 2011

I wrote a Socket Client which will send the Socket Server some data and get some response from Server. This process will be running once in every 2 seconds.

Now what I need to know is How we can identify the connection lost between Server and Client?

I need this to be implemented in the Client side. If there is no connection then Client should automatically close the connection. Once the connection with the server is available in the next attempt it should connect automatically.

View 1 Replies

Client Socket - Send Message Through Client Socket Receive Specified Argument Was Out Of Range Of Valid Values

Oct 15, 2011

Below is my code, but when i send the message thru client socket i receive Specified argument was out of the range of valid values. Parameter name: size

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim serverStream As NetworkStream = clientSocket.GetStream()
Dim outStream As Byte() = _
System.Text.Encoding.ASCII.GetBytes("0800822000000000000004000000000000000920092126012345001")

[CODE]...

View 1 Replies

How To Approach A Timing

Dec 15, 2011

OK, I have this loop I want to perform which involves the serial port. Not to get too specific I'm actually sending data to an external device within a loop The loop involves a Start number, increments by a Step and ends when it gets to Stop This repeats until I click a STOP button.

View 15 Replies

Best Approach For Data Manipulation?

Jul 28, 2009

I understand that there are several ways of Inserting, Updating and Deleting records in a database such as DataAdapters, DataSets, TableAdapters, SqlCommandBuilders, Parameterized SqlCommands, StoredProcedures, etc, etc,etc. According to David Sceppa Sprocs are the most preferred. Ok, I go with him on this one (who am I to challenge him anyway?).

My question is, apart from Sprocs, which of these options is the BEST for a large commercial database application and why, taking performance into account? What are the benefits and drawbacks of each option?

View 4 Replies

Best Approach To Update A Database?

Jul 18, 2009

I am writing a program to assist Paramedic students in learning the Drugs that they have to know in order to pass their classes. I have created an Access database to hold all the information on these drugs, but not every student that will use this program will need to learn all the drugs contained within this database.

Right now I have 43 drugs in the database and still growing.

What I want to do is to present to the student the drugs and have them say "Y" or "N" as to whether its on their required list to learn. That way they only work on the ones that they need to.

View 3 Replies

BGW With Similar Coding But Different Approach?

May 18, 2012

I've two BGW with similar coding but different approach, My second BGW shows me "NOT RESPONDING" whenever i try move/click/focus to form while the BGW is running.

VB
RichTextBox2.AppendText("Some Text")
process2.ReportProgress(inc)
My.Computer.Network.DownloadFile(andpic, "pics/" & spliti(0) & nnum & ".png")
My.Computer.Network.UploadFile("pics/" & spliti(0) & nnum & ".png", "ftp://ftp.mywebsite.com/domains/mywebsite/public_html/Pics/" & spliti(0) & nnum & ".png", "users", "password")
WebBrowser1.Navigate("Mywebsite")

I've taken out number of things that i think is causing this error Are they the cause of "NOT RESPONDING" ?

View 4 Replies

C# :: Which Of These Is The Better Architecture/design Approach

Nov 12, 2010

To write a effecient Active Directory library to ease the work of technicals who are responsible to create access models into the domain controller's Active Directory. This library must allow the following:Basic operations: Add, Modify, Delete, List entries;An entry may either be an organizational unit, group or user (no further need required as of now);I thought about having a class which would represent the domain with which we want to work with.

public class Domain {
public Domain(string root) {
Root = root;

[code].....

View 1 Replies

DataGridView And Two Tables - Best Approach?

Aug 26, 2009

I have a database with three tables:
stock
orders
order_details

Stock and Orders are self explanatory. Order_details is a lookup table, holding basically just the orderID, stockID and quantity for each item in the order. That's not very friendly for the user however, so what I want to show is a DataGridView with some elements from order_details, and some from stock, i.e.:
Part_Code, Item_Name, Description, Quantity, Price

I can create a database view for this easily enough, and bind it to a datagridview. It shows existing items in the order fine, but the problem is the view doesn't update when I add new elements to order_details in the dataset. It appears that it's bound to the main database, and so won't update until I save the record. That also has the problem that it's now much harder to update the database. A simple datagridview bound to order_details would make it easy for the user to enter quantities and for me to save the record, this one now needs a custom update statement.

In summary:
- I want to show data from two tables
- I want the datagridview editable (well, the quantity column anyway)
- I want the datagridview to update when I add entries in the dataset
What is the best/easiest way to do this? Is my current approach of a view in the database and custom update statements sensible? How can I get the datagridview to refresh whenever there's a change to the local dataset?

View 8 Replies

How To Approach Refactoring A Class

Jul 24, 2009

I recently started a project and needed to do some integration with LDAP via DirectoryServices. I've done this in other apps so I went into one of them to see how I did it -- why reinvent the wheel right? Well, while this wheel works, it was developed years ago and kinda smells (it's wooden, firmly attached to the previous vehicle, hard to repair and produces a potentially bumpy ride).So I thought to myself, this is the perfect time to refactor this puppy and make it more portable, reusable, reliable, easier to configure etc. Now that's fine and dandy, but then I started feeling a tad overwhelmed regarding to where to start. Should it be a separate library? How should it be configured? Should it use IoC? DI?

So my [admittedly subjective] question is this -- given a relatively small, but quite useful class like the one below, what is a good approach to refactoring it? What questions do you ask and how do you decide what to implement or not implement? Where do you draw the line regarding configuration flexibility? [Note: Please don't bash this code too much okay? It was written a long time ago and has functioned perfectly well baked into an in house application.]

Public Shared Function AuthenticateUser(ByVal id As String, ByVal password As String) As Boolean
Dim path As String = GetUserPath(id)

[code]......

View 5 Replies

How To Approach Scenario / Approve Changes

Apr 11, 2010

I'm working on a system where there can be 2 level of users "Admin" or "Researcher".We have the requirement to allow the researcher to change fields for a record a record, but they want the original values to stay in the record and have an admin "accept" or "approve" the changes before the real record gets updated.Has anyone run into this scenario before? I'm trying to think of the best way to do this.

View 3 Replies

Implement A Recordset Approach?

Oct 15, 2009

Trying to implement a recordset approach in VB.NET and have gotten to the point where things almost run. :)

Code:

Dim strSQL As String
Dim rsMaster As New ADODB.Recordset
strSQL = "select * " & "from tblDQ " & "order by xid, xcode, xDOS"

[Code].....

View 4 Replies

VS 2010 Best Way To Approach Reports?

Mar 25, 2012

I'm currently working on a system that requires monthly, quarterly and annual reports. I have no problem in generating/retrieving the data, my problem is the presentation. What is the best way to do it? I need the report to be:

View 3 Replies

.net - What Is The Optimal Approach To A WithEvents Collection

Mar 5, 2010

What is the optimal approach to a WithEvents Collection - VB.NET?Have you any remarks on the code bellow (skipping the Nothing verifications)?The problem is when I obtain the LinkedListNode(Of Foo) in a For Each block I can set myNode.Value = something, and here is a handlers leak...

-Could I override the FooCollection's GetEnumerator in this case?
-No. :( cause NotInheritable Class LinkedListNode(Of T)
Class Foo

[code]....

View 3 Replies

Approach For State Machine / Engine?

Oct 25, 2011

I was wondering about what approach to take for writing a state machine or data crunching engine.As such, it wouldn't have any UI component. Since it must be able to talk to other GUI programs, should it be hosted in a DLL? I noticed that there were some State Machine templates for VB but I have no idea how to use them. If
any one could provide some pointers to documentation sample code,

View 3 Replies

Approach On Finding Next Word In A String?

Apr 2, 2009

any other approach on finding next word in a string. What im trying solve is this.

Lets say this is the whole paragraph.

Hello visual basic
Hello visual basic
Hello visual basic
Hello visual basic
Hello visual basic
Hello visual basic

now i search for the word basic.if i press the button find. the first "basic must highlighted, and then if i press again the button the next "basic" is the highlighted one and so on.I already finsih that scenario. What i've done is that first im going to search all the positions of the word and then store it in a array. Then after the array populated with different location of the word that is searching. that is the time i call all the indexes of the array one by one. But i don't want my approach because imagine i have 10000 words. and i search for a word or letter. Lets say the result is 5000 match. so it needs my array to be size in 5000. what a mess in memory.

I don't want to used the FinsString or Find function of VB i want some algorithm to do this. Anyone have a easy approach..

View 5 Replies

Best Approach To Link App To Access Database?

Jun 3, 2011

How to link my app to an Access database - there seems to be a number of approaches. I can add in my database via the Data Sources tab. Fine if I want to bind controls and view/edit data. But is this the best approach for queries that return an answer that is a different shape to the original table? Alternatively I can connect to the database directly (connection string, etc) and run sql queries. What are advantages/disadvantages of each approach? In terms of flexibility, is the second approach best? Also, does the second approach require the database to be added via the Data Sources tab?

View 4 Replies

Best Approach To Update Wrapped Object?

Apr 24, 2012

I'm using VB.NET but this question applies to any OO language - Java, C# etc. I've tagged the question with Java and C# but will remove if not considered appropriate. I have an entity class ClassAAA that contains a reference to ClassBBB as one of it's attributes:

Public Class ClassAAA
Private Property _blah As ClassBBB = Nothing
Private Property _somethingElse As String
Private Property _anotherthing As String
' Make it private so cannot instantiate class without supplying ClassBBB '
[Code] .....

I could make the ClassBBB reference public (or supply a public getter method) but that would expose the inner workings of ClassAAA. What I'm thinking of doing is making the ClassBBB reference Friend so that it is only visible in the assembly i.e. a data layer and is not visible to client projects. But this stills feel like I'm exposing the inner workings of the class.

View 3 Replies

DB/Reporting :: General Approach To A Db Project?

Sep 8, 2010

DB/Reporting :: General approach to a db project

View 2 Replies

Recommended Approach For Copying Elements

Jan 30, 2010

Which is the recommended approach for copying elements from one control to another? Currently I am using something like this:
For Each a As Control In control.Controls
Controls.Add(a)
Next
Should I stick to it, or should I change to use the ControlCollection.CopyTo method instead?

View 3 Replies

Right Approach For Objects That Belong To Categories

Feb 3, 2010

I want to know what's the right way to work with objects that belong to a category.I'm building an applications with the following layers:Base data access Data access Business logic + Factories Presentation.I want to pass only objects to the presentation layer and back.I have objects (Employees), that belong to a certain category (EmployeeCat). I was wondering if I should have just an EmployeeCatID property in my Employee class/object, or an EmployeeCat property that contains a complete category object.If I want to fill a GridView with a list of employee objects as datasource, and I used just an ID in my Employee objects, then I will have some work at the presentation level to display the category names, so I think. On the other hand, if the list of employees contains plain category objects... I'm not sure what will happen.

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved