C# - Can't Exit A Loop With Multiple Buffer Transfer Over TCP / Sockets .net
Oct 26, 2011I'm transfering data over TCP/Sockets with the .Net (System.Net.Sockets) I am using this code on client side :
[Code]....
I'm transfering data over TCP/Sockets with the .Net (System.Net.Sockets) I am using this code on client side :
[Code]....
(First time trying to do socket programming ) I'm trying to read a large buffer using sockets. Is there anything wrong with this psudo code?
DO
mySocket.Receive(buff) ' temporary buffer, discard the data
WHILE (mySocket.Available > 0)
it terminates after the first iteration because, I suppose, it reads the data faster than the sender is sending it, and Socket.Available will be 0 (if i break the debugger and step through it, it receives the whole buffer). How can i make the Receive call block until more data is available? (I've tried setting Socket.ReceiveTimeout, but it doesn't seem to do any good)
I'm attempting to discard the contents of a System.Net.Sockets.Socket send buffer using theSocket.IOControl(IOControlCode.Flush, .... Does anybody know whether VB.NET supports this command? I've tried supplying 'Nothing' and 'Nothing' for both required parameters, also empty and populated byte arrays in combination with 'Nothing' for both required parameters, but I consistently get an 'Invalid argument' exception. I've tried a web search for an answer, but the only mention I've found was a question asked about 8 years ago, with still no answer.
View 1 RepliesHow do I exit from the recursive loop from the code below. I would like to notify the end-user to select a checkbox in a msgBox before I exit the loop.
[Code]....
I want to allow the user to exit out of a find - replace operation, but I also need to block input during the operation, so I was using this Declare Function BlockInput Lib "User32" (ByVal fBlockIt As Boolean) As Boolean Private Declare Function GetInputState Lib "user32" () As Int32
[Code]...
how to exit out of the Application.Do() as i am hanging in that .Here is a sample of my code.
Imports PDFCreator
Imports System.Windows.Forms
Public Class Form1
[Code]....
I have a VB application where winsock is used. I want to convert it to VB.Net, so as I understand I should use System.net.sockets to do this.
But the problem is in the VB application multiple sockets are created by using the index feature of the winsock . example
Load Socket(isocket)
where isocket is an integer variable that is incremented each time, for a new connection request.
So how do I do the same, ie. open multiple sockets in vb.net?
How to create multiple sockets as an index
View 3 RepliesI have an array of IP addresses, and I want to send the same data to all of them. I could just send the loop code that sends data but I think there's a better way of doing this.
View 1 RepliesI would like to terminate a do until ....loop when future value is greater than 1000 without using a Exit or Continue statement.
Do Until inti > intMonths
decFutureValue = (decFutureValue + decMonthlyInvestment) * (1 + decMonthlyInterestRate)
If decFutureValue > 1000 Then
[code]....
How would i check to see if a file exits on a website before attempting to download it?Also in my code ive enclosed the instructions in Do loop and if the file doesnt exist i want to skip the code and loop to the next file.
View 6 Repliesi have this code
[Code]...
I want If A.Text = (detline(0)) the program show a msgbox (OK this) and after the msgbox to cl;ose the file and exit from soubroutine When the pointer reach the FileClose(ReadFile) i receive in Catch When an Err.Number 13 WHY??
I want to make it so when cancel is used it exits the loop but I need the Input as a decimal.
Do
txtItems.Text = intCounter.ToString
intCounter = intCounter + 1
msgInput = CDec(InputBox("Enter Item Price", "Item Price", ""))
decSubTotal = msgInput + decSubTotal
txtItemPrice.Text = msgInput.ToString("C2")
[Code] .....
Actually my problem is to stop a loop when i click on stop button. example:i have two buttons 'start' and 'stop' in start buttom i wrote a for loop as
[Code]...
Is it possible to transfer all row data stored in datatable to arraylist without using a loop ?
View 12 Replies[Code]...
This is my code for retrieving pictures, it was working before but then i accidentally deleted the table and i created it again with the same name and same fields. and now whenever i open the form with the picture, there was a message box error. it says Buffer cannot be null. Parameter name: buffer I don't know what i did wrong.
I am creating an application for a point of sale in a bar in which I have a form (frmTransactions) where there are some radio buttons to be selected (main groupbox), each radio button is exclusive, and some combo boxes in the second groupbox to be ticked, which are instead not exclusive.In this form I created a 'Print Invoice' button which opens the form invoice (frmInvoice) and there are some labels that display the text shown on the transactions form; although I managed to do fairly easily the part regarding the customers details I am now finding some difficulties with the part regarding the transactions selected.[code]...
View 7 RepliesI'm current doing a computer course at college, one unit being event driven programming - for this I must design and program a till interface?
- One being on each form I have a virtual receipt named lstbox, and I have multiple forms! The problem is the content of each form is not transfering to the next virtual receipt on the next form e.g. drinks selection form 1 you select a tea, it adds to the virtual receipt, but when you hit the button to go to the next selection form, the content of the virtual receipt does not carry over. Could you please help me ?
- Secondly, I have a payment form on my till interface which obviously allows the user to finalise the transaction by taking payment from a customer, what would be appropriate code to use for when working out customers change e.g. If you hit a �10.00 button for customers change, and the charge of the transaction is �6.00 - I wish for an output of amount of change to go to the customer!
Note - I have a vat, subtotal and total text box for where the data displays. So whether to take away from the total text box and work out change that way, or to use the correct variables in my program such as itemcost variable, order variable etc.
Events -
- Selection of item -
Private Sub PictureBoxchocolatebrownies_Click(sender As System.Object, e As System.EventArgs) Handles PictureBoxchocolatebrownies.Click
[code]....
I'm developing a program using VB 2005.I've tried to use the following instructions to "kill" the application
Application.Exit()
Environment.Exit(0)
(not at the same time)
[code]....
I'm having a bit of a problem getting my application to close properly. Basically I have one main form from which all other forms open. If a user tries to close that main form, I want to bring up a MessageBox asking if they want to exit the application.However, when I try to do that it asks the question twice. It seems that the Application.Exit() is triggering the FormClosing event again for some reason, but I don't know of another way to exit the application. BTW, the main form isn't the startup form so I can't use the option to close when the startup form closes.
View 9 RepliesNow I have a sub to validate a bunch of textboxes and combo boxes.I previously used many IF statements to validate and pop up different messageboxes and Exit Sub in every IF statement.But I heard that too many Exits will decrease the efficiency and they were not recommended to use. Instead, nested IF is better because it will let the process naturally go to the end.Then I found out that if I use nested IF,it will be hard to read, since messageboxes are all separated from conditions.
View 2 RepliesI will use the Background Intelligent Transfer Service (BITS) to transfer files from a client (laptop) to a shared folder on a server within our local network.The problem is a very slow network bandwith, if we transfer a file, the other clients can´t work, all requests to other clients (application) or viewing internet pages needs a long time.My idea is to use BITS in my tool to copy/transfer a file from client to server, also I hope to get more performance for the internet requests.
View 2 RepliesIn VB.NET 2008 I've two forms 1 & 2 containing two datagridviews connected to two data source 'ACCESS 2007 tables' Now I want to select multiple rows from one datagridview (form1) & transferring these to another empty datagridview (form2) with a button_click.
View 3 RepliesI'm new to this, so sorry if my question has been asked before. I have searched but have not been able to find, or perhaps recognise, an answer. I am using visual studio 2008 and creating an app in vb.net.
I have 4 arrays named:- account1 account2 account3 account4. They all have 4 elements.I want to assign values to the elements in the arrays in an efficient manner. I thought two for next loops would do it. [code]....
I read the lines from a textfile into a string array and then I use a foreach loop on the string array. I want to go through the same string array again after the loop reach the end of the string array
View 1 RepliesI have a piece of code that loops through the rows in a database and brings out information.
The code is attached to a button(search). To search for data, you enter a phone number, the loop goes through the data rows and bring out the information is it is there.
Everything works great accept I have added a second table to the database.
So do I add a whole new loop statement? Example lets say I had a new data row, how can I add that to this statement so that both tables are searched?
This is the code:
Dim strGetRecord As String = masTxtPhoneField.Text
For validData = 0 To storedtData.Rows.Count - 1
If strGetRecord = storedData.Rows(validData)("fldphone").ToString Then
[Code].....
i want to set 2 conditions for a for loop as i want to loop through the same line of code at the same time . here it is as i have it now
it does not work how i want it to as i want both loops to run simuntaneously instead it runs the first loops continuously before the second and way around this?
For Me.i = 0 To maxrows - 1
For Me.h = 1 To maxrows
Me.Controls.Item("TextBox" & Me.h).Text =
[Code].....
The problem I am having is with a loop that I want to clear multiple textboxes
Dim count as double = 0
dim max as double = 6
Do Until count = max
textcommand = ("Textbox_"+ count +".clear()")
+Textcommand+
count = count + 1
Loop
[Code] .....
I'm trying to loop the inputbox 5 times but I'm not sure how.
Dim payroll1 As String
payroll1 = InputBox("What is the payrolls for store1", "Inc", , , )
Lblstore1.Text = payroll1
I can get it to loop till a specific amount but not 5 times exactly.
I would like to loop over two string arrays but does not work.[code]...
View 4 Replies