|
Hi,
Kindly note that, while capturing network incoming tcp packets using following codes/methods, missing some packets. It is sure that all packets all coming on my network perfectly fine but unfortunately I am missing some packets. Please let me know, what and where, I am doing mistake in my following mentioned codes.
Thank you & Regards
(Riaz)
public void Capture()
{
_mainSocket = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IP);
_mainSocket.Bind(new IPEndPoint(IPAddress.Parse("192.168.1.10"), 0));
var byTrue = new byte[] { 1, 0, 0, 0 };
var byOut = new byte[] { 1, 0, 0, 0 };
_mainSocket.IOControl(IOControlCode.ReceiveAll, byTrue, byOut);
_mainSocket.EnableBroadcast = true;
_mainSocket.BeginReceive(_data, 0, _data.Length, SocketFlags.None, OnReceive, null);
}
private void Parse(byte[] data, int size)
{
ipH = new IPHeader(data, size);
if (ipH.ProtocolType == Protocol.TCP)
{
FilterData(data, size);
}
System.Threading.Thread.Sleep(5);
}
private void FilterData(byte[] data, int size)
{
}
|
|
|
|
|
Don't you think that by putting your thread to sleep that you're killing your performance for no reason? 5 milliseconds can be an eternity in the view of a packet.
Also, packets can arrive so fast that you're not going to be able to process them at the same speed that they show up. You really need to have a FIFO buffering system between the receive code and the Parse/Filter code.
|
|
|
|
|
thanks for your suggestion
|
|
|
|
|
Interesting bit of code, although the implementation of OnReceive is not shown. The code suggest that your packets are TCP, so why are you not specifying that when you create the socket?
When I do this sort of thing (in TCP), I normally listen on a socket and accept connections, so I'm not sure what's going on here.
One possibility is that your code is not keeping up with the incoming packets, especially with the 5ms sleep that Dave points out. You could try increasing the receive buffer on the socket to test this assertion. And definitely get rid of the sleep.
If you update your code with the pertinent OnRecieve, that would provide more clues.
Regards,
Rob Philpott.
|
|
|
|
|
thanks for your suggestion
|
|
|
|
|
Hi all
why does this form freeze when I press the strtChatBtn at the second time?
Server Form Class
public partial class Server_Design : Form
{
Thread serverStart;
private bool btnStartStop = true;
public Server_Design()
{
InitializeComponent();
}
private void Server_Design_Load_1(object sender, EventArgs e)
{
}
private void strtChatBtn_Click(object sender, EventArgs e)
{
if (btnStartStop)
{
serverStart = new Thread(new ThreadStart(Connection.StartListen));
serverStart.Start();
strtChatBtn.Text = "Stop Chat";
btnStartStop = false;
}
else
{
this.serverStart.Abort();
Connection.StopListen();
strtChatBtn.Text = "Start Chat";
btnStartStop = true;
}
}
}
}
Connection Class
public static class Connection
{
static IPAddress srvIP = IPAddress.Parse("127.0.0.1");
static int srvPort = 8888;
static TcpListener server = new TcpListener(srvIP, srvPort);
public static void StartListen()
{
server.Start();
while (1 != 0)
{
TcpClient client = server.AcceptTcpClient();
NetworkStream ns = client.GetStream();
StreamWriter sw = new StreamWriter(ns);
StreamReader sr = new StreamReader(ns);
ns = client.GetStream();
client.Close();
ns.Close();
sw.Close();
sr.Close();
}
}
public static void StopListen()
{
server.Stop();
}
}
}
|
|
|
|
|
I don't know, but it's generally not a good idea to use Abort. Try using a semaphore instead.
bool listen = false ;
Before starting the thread, set the semaphore to true .
In the thread use while ( listen )
Before stopping, set the semaphore to false , then use this.serverStart.Join to wait for the thread to exit.
http://msdn.microsoft.com/en-us/library/95hbf2ta(v=vs.110).aspx[^]
|
|
|
|
|
I want to generate summary report in GridView.
my database raw table is:
Table1
id userID feedBack timeStamp
1 user1 Excellent 2014-08-07 14:50:22.000
2 user2 Average 2014-08-07 14:50:42.000
3 user3 Good 2014-08-07 14:51:20.000
4 user4 Poor 2014-08-07 14:55:25.000
5 user1 Good 2014-08-07 14:57:02.000
based on that database table.
I want to show summary report in GridView as follow.
Report1
Input: DateRange
UserID Excellent Good Average Poor
user1 1 1 0 0
user2 0 0 1 0
user3 0 1 0 0
user4 0 0 0 1
that is , what I want to show in GridView .
it is more clear so that you friends can help me.
regards
modified 15-Aug-14 4:16am.
|
|
|
|
|
You need to use a PIVOT query on the data
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
Oh Oh wait a chance for self promotio[^]n
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Whenever i look profile for interview, every one ask for share point and silver light. i don't understand it and its scope. please share what is the scope of sharepoint and silver light
RamK
|
|
|
|
|
Firstly this question has nothing to do with C#. And secondly, you need to make the effort to answer such questions for yourself. There is a wealth of information available to explain the basics of both technologies, at least enough for you to decide which one you want to learn.
|
|
|
|
|
Please how can I achieve this in a datagridview that when data is fetched from database, that each combo box will show a dropdown of the value of the Quantity it has fetched.
for an instance, if x gets 10,12,15,9,5,3
the first combobox will show a dropdown of 1 to 10, the second will show 1 to 12,...
DataGridViewComboBoxColumn dv = new DataGridViewComboBoxColumn();
dv.HeaderText = "myCombobox";
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "Select * from Toolz";
conn.Open();
reader = cmd.ExecuteReader();
while (reader.Read())
{
x = Reader.GetInt32(3);
}
foreach (DataGridViewRow dvx in dataGridView3.Rows)
{
y = Convert.ToInt32(dvx.Cells[3].Value.ToString());
}
for (g = 0; g < y; g++) ;
List<int> xl = new List<int>();
xl.Add(g);
foreach (DataGridViewComboBoxColumn dvx in dataGridView3.Rows)
{
dv.Items.Add(xl);
}
Keep the Dream Alive..
|
|
|
|
|
Please do not cross post.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I am testing a communicator frame where I have blocks of message contents which are pulled from database using visual studio telerik framework.
each message in database represents a Div on the UI.
each div has path something like
`
Pages.CareMechanix.FrameCommunicator.DOBDiv
Pages.CareMechanix.FrameCommunicator.DOBDiv0
Pages.CareMechanix.FrameCommunicator.DOBDiv1
Pages.CareMechanix.FrameCommunicator.DOBDiv2
`
I am getting the number of divs by `Pages.CareMechanix.FrameCommunicator.Find.AllByAttributes("class=cm-alert").Count;`
I am verifying if the number of messages in database is equal to number of divs.
In similar way, I want to verify the content in each div content is equal to corresponding message in database.
I would definitely not want to access each div content separately by path like below:
`Pages.CareMechanix0.FrameCommunicator.**DOBDiv**.AssertContent().TextContent(ArtOfTest.Common.StringCompareType.Contains, "| DOB: 00/27/1974" + "Patient ID: " + PatientID + sub);
Pages.CareMechanix0.FrameCommunicator.**DOBDiv0**.AssertContent().TextContent(ArtOfTest.Common.StringCompareType.Contains, "| DOB: 00/27/1974" + "Patient ID: " + PatientID + sub);
Pages.CareMechanix0.FrameCommunicator.**DOBDiv1**.AssertContent().TextContent(ArtOfTest.Common.StringCompareType.Contains, "| DOB: 00/27/1974" + "Patient ID: " + PatientID + sub);`
I would like to run a loop for the count to verify the text content.
**I am not sure of how to get each div content using a loop.**
Can someone please help me on this?
Please let me know if I am not clear anywhere.
I can explain.
|
|
|
|
|
Hello,
I am trying to work out the best way to play a video in full screen without the form displaying..
I have added the axWindowsMediaPlayer player to my form but I just cannot work out how to make it play full screen.
I have tried the code:
axWindowsMediaPlayer1.windowlessVideo = true;
But it seems to make no difference.
Ideally I am trying to make the video play full screen without any controls.
Can anyone suggest the best way to achieve this please?
Thanks
Trev
|
|
|
|
|
A quick Google shows me this AxWindowsMediaPlayer.fullScreen property[^]
if that doesn't work as expected I think you need to elaborate on your requirements
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Hi Simon,
Many thanks.
Apologies, I should have said I did try that as well..
When I do I get an error:
here is my code:
private void axWindowsMediaPlayer1_Enter(object sender, EventArgs e)
{
axWindowsMediaPlayer1.URL = @"C:\Users\trevo_000\Documents\visual studio 2013\Projects\Lance\Video Player\Loop.mp4";
axWindowsMediaPlayer1.fullScreen = true;
axWindowsMediaPlayer1.windowlessVideo = true;
}
And I get the error of:
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in AxInterop.WMPLib.dll
Additional information: Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
Trev
|
|
|
|
|
You might want to read the documentation on the FullScreen property[^] and make sure you're setting up the MediaPlayer within the limits specified.
|
|
|
|
|
ok. can I go back to basics please? as I think I might be doing this wrong...
What am I trying to achieve...?
I am trying to write an app that, when it starts, immediately goes fullscreen and starts playing a video.
I then want the video to keep looping unless I tell the "video player" to change video.
I mostly write websites and APIs so my knowledge is way out of date in this area.
Is WMP the way to do this?
Thanks
|
|
|
|
|
Yes it is the way to do this.
No, it does not get you out of reading the documentation.
|
|
|
|
|
Member 4169628 wrote: immediately goes fullscreen All the examples I've seen set the fullscreen mode only when the state of the Player is Playing!
|
|
|
|
|
Hi,
i have a very strange problem with CheckBox ComboBox Extending the ComboBox Class and Its Items[^]
First, i have two of them on my form. When I check a Item in one of them, i call a method that reloads the entries of the second ComboBox consider which Item was selected in the first ComboBox, after that the method checks the Items which was checked before the entries of the second ComboBox were reload. This should work in two ways.
It works fine when I Select one Item in the first ComboBox and one item in the second ComboBox (My Method checks the "earlier checked Items of the other ComboBox") but when I select two or more Items in the second ComboBox the method dont checks the "earlier checked Items". I hope it was unterstandable, my english isn't the best...please ask when you have any questions.
Here is my Code.
1. ComboBox (cbArticle) CheckBoxCheckedChanged Event:
private void cbArticle_CheckBoxCheckedChanged(object sender, EventArgs e)
{
if (cbArticle.Text != "Artikel auswählen")
{
cbArticle.ForeColor = SystemColors.WindowText;
GetQueryType(gbTimespan.Controls.OfType<RadioButton>().FirstOrDefault(n => n.Checked));
string[] arrMethods = cbMethod.Text.Split(',');
cbMethod.Items.Clear();
FillMethods();
cbMethod.CheckBoxCheckedChanged -= cbMethod_CheckBoxCheckedChanged;
for (int i = 0; i < arrMethods.Length; i++)
{
try
{
cbMethod.CheckBoxItems[arrMethods[i].Trim()].Checked = true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
cbMethod.CheckBoxCheckedChanged += cbMethod_CheckBoxCheckedChanged;
}
else
{
cbArticle.ForeColor = SystemColors.GrayText;
FillMethods();
if (finished)
{
GetQueryType(gbTimespan.Controls.OfType<RadioButton>().FirstOrDefault(n => n.Checked));
}
}
}
2. ComboBox (cbMethod) CheckBoxCheckedChanged Event:
private void cbMethod_CheckBoxCheckedChanged(object sender, EventArgs e)
{
if (cbMethod.Text != "Methode(n) auswählen")
{
cbMethod.ForeColor = SystemColors.WindowText;
GetQueryType(gbTimespan.Controls.OfType<RadioButton>().FirstOrDefault(n => n.Checked));
string[] arrArticles = cbArticle.Text.Split(',');
cbArticle.Items.Clear();
FillGroupCodes();
cbArticle.CheckBoxCheckedChanged -= cbArticle_CheckBoxCheckedChanged;
for (int i = 0; i < arrArticles.Length; i++)
{
try
{
cbArticle.CheckBoxItems[arrArticles[i].Trim()].Checked = true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
cbArticle.CheckBoxCheckedChanged += cbArticle_CheckBoxCheckedChanged;
}
else
{
cbMethod.ForeColor = SystemColors.GrayText;
FillGroupCodes();
if (finished)
{
GetQueryType(gbTimespan.Controls.OfType<RadioButton>().FirstOrDefault(n => n.Checked));
}
}
}
When I debug the Code it works fine every time. I can see that the checkbox CheckedStatus is checked. But when the Method has ended and my Application switches back to the UI the CheckBoxes aren't checked... I call no other Methods (checked in debugger) but I can see that the CheckBoxComboBox.cs opens in Visual Studio it jumps in the following Code Blocks.
public partial class CheckBoxComboBox : PopupComboBox
{
#region EVENTS & EVENT HANDLERS
public event EventHandler CheckBoxCheckedChanged;
private void Items_CheckBoxCheckedChanged(object sender, EventArgs e)
{
OnCheckBoxCheckedChanged(sender, e);
}
#endregion
#region EVENT CALLERS and OVERRIDES e.g. OnResize()
protected void OnCheckBoxCheckedChanged(object sender, EventArgs e)
{
string ListText = GetCSVText(true);
if (DropDownStyle != ComboBoxStyle.DropDownList)
Text = ListText;
else if (DataSource == null)
{
Items[0] = ListText;
CheckBoxItems[0].ComboBoxItem = ListText;
}
EventHandler handler = CheckBoxCheckedChanged;
if (handler != null)
handler(sender, e);
}
...
}
[ToolboxItem(false)]
public class CheckBoxComboBoxItem : CheckBox
{
#region PROTECTED MEMBERS
protected override void OnCheckedChanged(EventArgs e)
{
if (_CheckBoxComboBox.DataSource != null)
{
PropertyInfo PI = ComboBoxItem.GetType().GetProperty(_CheckBoxComboBox.ValueMember);
PI.SetValue(ComboBoxItem, Checked, null);
}
base.OnCheckedChanged(e);
if (_CheckBoxComboBox.DataSource != null)
{
string OldDisplayMember = _CheckBoxComboBox.DisplayMember;
_CheckBoxComboBox.DisplayMember = null;
_CheckBoxComboBox.DisplayMember = OldDisplayMember;
}
}
#endregion
Please help me...I am totally frustrated after sitting 2-3 days on this issue...
|
|
|
|
|
If you have a question on an article, the best place to ask is in the forum at the bottom of that article: Comments[^]
The author of the article is usually the best person to help with the code they've written.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Of course, but I think the autho of this article is no longer active.
|
|
|
|